判断进程是64bit还是32bit
#pragma
region
Includes
#include
<stdio.h>
#include
<windows.h>
#pragma
endregion
BOOL DoesWin32MethodExist(PCWSTR pszModuleName, PCSTR pszMethodName){
HMODULE hModule = GetModuleHandle(pszModuleName);
if (hModule == NULL){
return FALSE;
}
return (GetProcAddress(hModule, pszMethodName) != NULL);
}
BOOL Is64BitOperatingSystem(){
#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
BOOL f64bitOS = FALSE;
return (DoesWin32MethodExist(L"kernel32.dll", "IsWow64Process") && (
IsWow64Process(GetCurrentProcess(), &f64bitOS) && f64bitOS));
#else
return FALSE; // 64-bit Windows does not support Win16
#endif
}
BOOL Is64BitProcess(HANDLE hProcess)
{BOOL f64bitProc = FALSE;
if (Is64BitOperatingSystem())
{
f64bitProc = !(IsWow64Process(hProcess, &f64bitProc) && f64bitProc
);
}
return f64bitProc;
}
int wmain(int argc, wchar_t* argv[])
{if (argc> 1)
{
DWORD dwProcessId = _wtoi(argv[1]);
if (dwProcessId == 0 /*conversion failed*/){
wprintf(L"Invalid process ID.\n");
return 1;
}
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
if (hProcess != NULL){
BOOL f64bitProc = Is64BitProcess(hProcess);
wprintf(L"The process is a %bit process.\n", f64bitProc ? L"64" : L"32");
CloseHandle(hProcess);
}
else
{wprintf(L"OpenProcess(%d) failed w/err 0x%08lx\n", dwProcessId, GetLastError());
}
}
else
{
BOOL f64bitProc = Is64BitProcess(GetCurrentProcess());
wprintf(L"Current process is a %bit process.\n", f64bitProc ? L"64" : L"32");
}
return 0;
}
http://www.cnblogs.com/lzjsky/archive/2010/12/01/1893169.html
判断进程是64bit还是32bit的更多相关文章
- INNO setup安装卸载钱判断进程中是否在运行总结
1.安装前判断进程中是否有程序在运行. [files] ; 安装前判断进程,dll文件放在inno的安装目录中Source: compiler:psvince.dll; Flags: dontcopy ...
- Shell实现判断进程是否存在并重新启动脚本
Shell实现判断进程是否存在并重新启动脚本 - superbfly的专栏 - CSDN博客 https://blog.csdn.net/superbfly/article/details/52513 ...
- inno setup 安装前判断进程是否存在,以及停止相应进程<转>
打包的时候遇到了这样的需求:假似用户都是傻瓜 式操作,如果更新安装程序的时候,之前的老程序还在运行这个时候如果你去提示让用户吧老程序手动退掉也不现实. 所以当遇到这种 ...
- linux脚本-判断进程是否存在,从而可以做预警处理..
count=`ps -ef | grep Seeyon | grep -v "grep" | wc -l` echo $count if [ $count -gt 0 ]; the ...
- DOS中判断进程是否存在的方法
这里分享的主要是通过批处理中先判断进程是否存在,然后再做出操作的实现代码,需要的朋友可以参考下 检测进程是否存在,并做出预定动作. tasklist /nh>d:\tddown~1\1.tx ...
- C++ 判断进程是否存在
原文:http://blog.csdn.net/u010803748/article/details/53927977?locationNum=2&fps=1 一.判断指定程序名的进程是否存在 ...
- 一个电脑同时运行 64bit 和 32bit 的eclipse 如何匹配 jdk环境
一个电脑同时运行 64bit 和 32bit 的 eclipse 如何匹配 jdk环境 1 eclipse 分 64bit 和 32bit 两种. 64bit的eclipse 只能搭配 64b ...
- erlang中判断进程是否存活
一个参数的方法是已知Pid判断进程是否存活.两个参数的方法是已知节点和Pid或进程名判断进程是否存活. is_process_alive(Pid) when is_pid(Pid)->rpc:c ...
- 3 Ways to Learn Whether a Windows Program is 64-bit or 32-bit
More than 90% of Windows 8.1 installations are 64-bit and, as a result, more and more people use 64- ...
随机推荐
- Ubuntu 12.04 下安装git
---恢复内容开始--- 1.安装build-essential. 列出Git相关包(git-core 和 git-doc)所以来的各个安装包并安装: sudo apt-get build-dep g ...
- IIS7.0 部署wcf 404或者配置MIME(转)
WCF部署在IIS下,报错如下: 应用程序“DEFAULT WEB SITE/IMF”中的服务器错误 Internet 信息服务 7.0 错误摘要 HTTP 错误 404.3 - Not Found由 ...
- GitHub问题之恢复本地被删除的文件
折腾了真久,GitHub commit之后,我手痒把本地的一个文件给删了,然后一直Git pull都发现不能恢复.远程库里面还是有该文件的.就是我想将远程库的文件回到本地被删除了的位置. 特别的是,我 ...
- 算法分析-快速排序QUICK-SORT
设要排序的数组是A[0]……A[N-1],首先任意选取一个数据(通常选用数组的第一个数)作为关键数据,然后将所有比它小的数都放到它前面,所有比它大的数都放到它后面,这个过程称为一趟快速排序.值得注意的 ...
- IC卡
本词条由“科普中国”百科科学词条编写与应用工作项目 审核 . IC卡 (Integrated Circuit Card,集成电路卡),也称智能卡(Smart card).智慧卡(Intelligent ...
- GDI+简单现实文字旋转
原文 http://www.cnblogs.com/kaixiangbb/p/3301272.html 题记 入职新公司已快有两月了,试用期已快结束,项目却迟迟还未正式启动.安排给我的多是些琐事,一直 ...
- 使用 rpython 在 windows 下生成的程序无法运行
在 windows 用rpython编译出的文件总是无法运行,报 通过跟踪发现,rpython 每次都会将生成的C代码.Makefile 等放置在 %TEMP%\usession-release-2. ...
- poj2136
Vertical Histogram Time Limit ...
- centos6.5 Eclipse C/C++开发环境及项目创建测试
1,新建C++ project
- c++ - How to use wstring and wcout to output Chinese words in Xcode? - Stack Overflow
c++ - How to use wstring and wcout to output Chinese words in Xcode? - Stack Overflow How to use wst ...