6

I need to know whether a given .exe is 32-bit or a 64-bit, before I launch it. IsWow64Process is no use here, since there is no process yet. Is there some other API that will give me this information?

JSBձոգչ
  • 40,684
  • 18
  • 101
  • 169
  • 1
    possible duplicate of [How to find if native dll is compiled as x64 or x86?](http://stackoverflow.com/questions/480696/how-to-find-if-native-dll-is-compiled-as-x64-or-x86) – Steve Townsend Nov 03 '10 at 17:17
  • Actually, I withdraw the dup - this is a lot easier for EXEs than for DLLs, it seems. – Steve Townsend Nov 03 '10 at 17:26

3 Answers3

12

If you really only want to do this for EXEs and not DLLs, just use GetBinaryType.

Determines whether a file is an executable (.exe) file, and if so, which subsystem runs the executable file.

Steve Townsend
  • 53,498
  • 9
  • 91
  • 140
  • Yes, this is *exactly* what I want, and it's much easier than reading the PE header myself, which is what the other answers suggested. Thanks. – JSBձոգչ Nov 03 '10 at 17:41
  • 1
    You are lucky you just need EXEs :-) Those complex contortions appear necessary to do this for DLLs. A gap in Win32, imo. – Steve Townsend Nov 03 '10 at 17:42
5

This post will surely help you.

Is C# related but it will give you the idea.

Community
  • 1
  • 1
Liviu Mandras
  • 6,540
  • 2
  • 41
  • 65
1

This information is available in one of the headers of the PE File file format (the format used for exe's and dll's). The information in these headers can either be extracted programmatically (they are at a specified offset) or more safely queried via the Win32 API.

Alright, Liviu got the correct pointer for you.

Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172