如何判断一个进程是32位还是64位?

66i88 2018-04-26 03:57:19
就像WIN10任务管理器中那样。

谢谢。
...全文
1527 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2018-04-27
  • 打赏
  • 举报
回复
IsWow64函数可以,拿到对应进程的句柄
worldy 2018-04-26
  • 打赏
  • 举报
回复
IsWow64Process Function Determines whether the specified process is running under WOW64. BOOL WINAPI IsWow64Process( __in HANDLE hProcess, __out PBOOL Wow64Process ); Parameters hProcess A handle to the process. Wow64Process A pointer to a value that is set to TRUE if the process is running under WOW64. Otherwise, the value is set to FALSE. Return Value If the function succeeds, the return value is a nonzero value. If the function fails, the return value is zero. To get extended error information, call GetLastError. Remarks If the application is a 64-bit application running under 64-bit Windows, the Wow64Process parameter is set to FALSE. To compile an application that uses this function, define _WIN32_WINNT as 0x0501 or later. For more information, see Using the SDK Headers. Example Code [C++] For compatibility with operating systems that do not support this function, call GetProcAddress to detect whether IsWow64Process is implemented in Kernel32.dll. If GetProcAddress succeeds, it is safe to call this function. Otherwise, WOW64 is not present. Note that this technique is not a reliable way to detect whether the operating system is a 64-bit version of Windows because the Kernel32.dll in current versions of 32-bit Windows also contains this function. #include <windows.h> #include <stdio.h> typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); LPFN_ISWOW64PROCESS fnIsWow64Process; BOOL IsWow64() { BOOL bIsWow64 = FALSE; fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); if (NULL != fnIsWow64Process) { if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { // handle error } } return bIsWow64; } void main() { if(IsWow64()) printf("Running on WOW64\n"); else printf("Running on 32-bit Windows\n"); }
Saleayas 2018-04-26
  • 打赏
  • 举报
回复
IsWow64Process
hgz_dm 2018-04-26
  • 打赏
  • 举报
回复
这个不是应该和系统相关的吗?系统是32位/64位的,进程应该就是32位/64位的啊

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧