tags:

views:

142

answers:

4

Is there a Windows API call that will tell me if I'm running on a 64-bit OS? I have some legacy c++ code that makes a call to GetVersionEx to fill in a OSVERSIONINFO structure, but that only tells me (AFAIK) the OS (Vista, V7, etc.), but not the processing architecture. I can hack around this by simply looking for the existence of "C:\Program Files (x86)...", but this seems ugly. I'm sure there must be an API to return this info.

+2  A: 

GetNativeSystemInfo()

Jerry Coffin
+3  A: 

IsWow64Process might be what you are looking for.

Michael
Just be aware that this function always returns false if run from a 64-bit application (because 64-bit apps aren't running in WoW64 mode).
R. Bemrose
Absolutely. (Of course, detecting whether the current application is a 64-bit application could be done at compile-time, e.g. via `_M_X64` in msvc)
Michael
+1  A: 

Take a look at this link. I assume you are indeed using VS since you're developing on Windows.

Cecil Has a Name
+1  A: 

I found this post that seems to provide a good answer: http://stackoverflow.com/questions/601089/detect-whether-current-windows-version-is-32-bit-or-64-bit

I don't know why it didn't come up when I search Stack Overflow before posting.

Incidentally, the best solution for me is to simply check for the ProgramW6432 environment variable.

Decker