BOOL WINAPI IsWow64Process(
__in HANDLE hProcess,
__out PBOOL Wow64Process
);
#include <windows.h> #include <tchar.h> typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); LPFN_ISWOW64PROCESS fnIsWow64Process; BOOL IsWow64() { BOOL bIsWow64 = 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. fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); if(NULL != fnIsWow64Process) { if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { //handle error } } return bIsWow64; } int main( void ) { if(IsWow64()) _tprintf(TEXT("The process is running under WOW64.\n")); else _tprintf(TEXT("The process is not running under WOW64.\n")); return 0; }
注意:使用此函数判断操作系统是32位还是64位并不合适,勉强要用的话,可以指向一个32位进程。
BOOL Is64bitSystem() { SYSTEM_INFO si; GetNativeSystemInfo(&si); if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ) return TRUE; else return FALSE; }
判断是64位操作系统还是32位系统,布布扣,bubuko.com
原文:http://www.cnblogs.com/guomeiran/p/3898718.html