Programatically determine if native .exe is 32-bit or 64-bit
Asked Answered
G

3

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?

Goldcrest answered 3/11, 2010 at 17:11 Comment(2)
possible duplicate of How to find if native dll is compiled as x64 or x86?Unconsidered
Actually, I withdraw the dup - this is a lot easier for EXEs than for DLLs, it seems.Unconsidered
U
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.

Unconsidered answered 3/11, 2010 at 17:25 Comment(2)
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.Fellatio
You are lucky you just need EXEs :-) Those complex contortions appear necessary to do this for DLLs. A gap in Win32, imo.Unconsidered
O
5

This post will surely help you.

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

Obstinate answered 3/11, 2010 at 17:16 Comment(0)
W
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.

Warring answered 3/11, 2010 at 17:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.