1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); bool Is64BitWindows() { #if defined(_WIN64) return true; // 64-bit programs run only on Win64 #elif defined(_WIN32) // 32-bit programs run on both 32-bit and 64-bit Windows // so must sniff BOOL f64 = FALSE; LPFN_ISWOW64PROCESS fnIsWow64Process; fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process"); if (NULL != fnIsWow64Process) { return !!(fnIsWow64Process(GetCurrentProcess(), &f64) && f64); } return false; #else return false; // Win64 does not support Win16 #endif } |
http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net
その他、CPUとプロセスが64ビットか調べる
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
typedef void(WINAPI *LPFN_GetNativeSystemInfo)(LPSYSTEM_INFO); LPCWSTR GetPlatformW() { static WCHAR sT[64]; static bool done = false; if (done) return sT; LPFN_GetNativeSystemInfo fnGetNativeSystemInfo = (LPFN_GetNativeSystemInfo)GetProcAddress( GetModuleHandle(TEXT("kernel32")), "GetNativeSystemInfo"); if (NULL == fnGetNativeSystemInfo) { lstrcpy(sT, L"Unknown"); } else { SYSTEM_INFO si = { 0 }; fnGetNativeSystemInfo(&si); switch (si.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: lstrcpy(sT, L"AMD64"); break; case PROCESSOR_ARCHITECTURE_ARM: lstrcpy(sT, L"ARM"); break; case PROCESSOR_ARCHITECTURE_IA64: lstrcpy(sT, L"IA64"); break; case PROCESSOR_ARCHITECTURE_INTEL: lstrcpy(sT, L"INTEL"); break; default:lstrcpy(sT, L"Unknown"); break; } } return sT; } bool Is64BitProcess() { #if defined(_WIN64) return true; #else return false; #endif } |
AMD64でしか実験してない。ARMやIA64ではどうなるのか不明。