- 注册时间
- 2021-4-16
- 最后登录
- 2023-11-9
- 在线时间
- 3 小时
编程入门
- 龙马币
- 52
|
c++ 判断windows系统和进程是32位还是64位
- BOOL Is64BitOS()
- {
- typedef VOID (WINAPI *LPFN_GetNativeSystemInfo)( __out LPSYSTEM_INFO lpSystemInfo );
- LPFN_GetNativeSystemInfo fnGetNativeSystemInfo = (LPFN_GetNativeSystemInfo)GetProcAddress( GetModuleHandleW(L"kernel32"),"GetNativeSystemInfo");
- if(fnGetNativeSystemInfo)
- {
- SYSTEM_INFO stInfo = {0};
- fnGetNativeSystemInfo( &stInfo);
- if( stInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64
- || stInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
- {
- return TRUE;
- }
- }
- return FALSE;
- }
- BOOL Is64BitPorcess(DWORD dwProcessID)
- {
- if (!Is64BitOS())
- {
- return FALSE;
- }else
- {
- HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,dwProcessID);
- if(hProcess)
- {
- typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
- LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( GetModuleHandleW(L"kernel32"),"IsWow64Process");
- if (NULL != fnIsWow64Process)
- {
- BOOL bIsWow64 = FALSE;
- fnIsWow64Process(hProcess,&bIsWow64);
- CloseHandle(hProcess);
- if (bIsWow64)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- }
- }
- return FALSE;
- }
复制代码 |
|