Detect 32-bit or 64-bit of Windows
The function to call is IsWow64Process
or IsWow64Process2
. It tells your 32-bit application if it is running on a 64 bit Windows.
If the program is compiled for 64 bits, it will already know.
If your code is 64-bit and running, then Windows is 64-bit - nothing to check. If your process is 32-bit call IsWow64Process()
- 32-bit processes run in WOW64 on 64-bit Windows and without WOW64 otherwise.
bool getWindowsBit(bool & isWindows64bit){#if _WIN64 isWindows64bit = true; return true;#elif _WIN32 BOOL isWow64 = FALSE; //IsWow64Process is not available on all supported versions of Windows. //Use GetModuleHandle to get a handle to the DLL that contains the function //and GetProcAddress to get a pointer to the function if available. LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); if(fnIsWow64Process) { if (!fnIsWow64Process(GetCurrentProcess(), &isWow64)) return false; if(isWow64) isWindows64bit = true; else isWindows64bit = false; return true; } else return false;#else assert(0); return false;#endif}