How to detect in a running C++/Qt application if underlying Windows is a 32 or 64 bit version? [duplicate]
Possible Duplicate:
Detect whether current Windows version is 32 bit or 64 bit Correct way to check if Windows is 64 bit or not, on runtime? (C++)
I found some questions on the topic, but not exactly what I need.
I'm developing a C++/Qt application that is completely cross-platform except for some precompiled .exe's the app开发者_如何学运维 has to run. (Only Windows is relevant to the question). I have 32 and 64 bits Windows versions of these executables. I know that one option would be to package two versions of the whole app, but the change in the code would be so minimal that I'd like to think of other alternatives.
So, is there a way to detect at runtime, using C++/Qt features, whether the underlying Windows is a 32 or a 64 bits version?
Thanks!
No, but you can call WINAPI functions to tell you this.
Call GetNativeSystemInfo(). If you're running x64, SYSTEM_INFO::wProcessorArchitecture
will be PROCESSOR_ARCHITECTURE_AMD64
. If 32 x86 bit it will be PROCESSOR_ARCHITECTURE_INTEL
精彩评论