日期:2014-05-17 浏览次数:21379 次
利用getSystemWow64Directory这个函数来判断 typedef UINT (WINAPI* GETSYSTEMWOW64DIRECTORY)(LPTSTR, UINT); BOOL IsWow64(void) { #ifdef _WIN64 return FALSE; #else GETSYSTEMWOW64DIRECTORY getSystemWow64Directory; HMODULE hKernel32; TCHAR Wow64Directory[MAX_PATH]; hKernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (hKernel32 == NULL) { // // This shouldn't happen, but if we can't get // kernel32's module handle then assume we are //on x86. We won't ever install 32-bit drivers // on 64-bit machines, we just want to catch it // up front to give users a better error message. // return FALSE; } getSystemWow64Directory = (GETSYSTEMWOW64DIRECTORY) GetProcAddress(hKernel32, "GetSystemWow64DirectoryW"); if (getSystemWow64Directory == NULL) { // // This most likely means we are running // on Windows 2000, which didn't have this API // and didn't have a 64-bit counterpart. // return FALSE; } if ((getSystemWow64Directory(Wow64Directory, sizeof(Wow64Directory)/sizeof(TCHAR)) == 0) && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) { return FALSE; } // // GetSystemWow64Directory succeeded // so we are on a 64-bit OS. // return TRUE; #endif }