if (NULL != fnIsWow64Process) { if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { // handle error MessageBox(NULL,TEXT("Can not fnIsWow64Process! "),TEXT("unknown errors"),MB_OK); return bIsWow64; } } return bIsWow64; }
------解决方案-------------------- 楼上的方法只对32位程序有效,如果将程序编译为x64版本,那么就无法区分出当前系统是x86还是x64,看MSDN中IsWow64Process函数的说明: A pointer to a value that is set to TRUE if the process is running under WOW64. If the process is running under 32-bit Windows, the value is set to FALSE. If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE.
一种通用且简单的方法判断系统是x64还是x86可以用如下代码:
C/C++ code
SYSTEM_INFO si;
GetSystemInfo(&si);
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 )
MessageBox(L"is x64 version",L"",MB_OK);
else
MessageBox(L"is x86 version",L"",MB_OK);
------解决方案--------------------