I am trying to find out if a given executable (or library) is compiled for 32-bits or 64-bits from Python. I am running Vista 64-bits and would like to determine if a certain application in a directory is compiled for 32-bits or 64-bits.
Is there a simple way to do this using only the standard Python libraries (currently using 2.5.4)?
The Windows API for this is
GetBinaryType. You can call this from Python using pywin32:If you want to do this without pywin32, you’ll have to read the PE header yourself. Here’s an example in C#, and here’s a quick port to Python: