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.
views:
142answers:
4Just 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
2009-10-29 21:00:25
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
2009-10-29 21:09:34
+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
2009-10-29 20:58:00
+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
2009-10-29 21:05:34