#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的更多相关文章

  1. INNO setup安装卸载钱判断进程中是否在运行总结

    1.安装前判断进程中是否有程序在运行. [files] ; 安装前判断进程,dll文件放在inno的安装目录中Source: compiler:psvince.dll; Flags: dontcopy ...

  2. Shell实现判断进程是否存在并重新启动脚本

    Shell实现判断进程是否存在并重新启动脚本 - superbfly的专栏 - CSDN博客 https://blog.csdn.net/superbfly/article/details/52513 ...

  3. inno setup 安装前判断进程是否存在,以及停止相应进程<转>

    打包的时候遇到了这样的需求:假似用户都是傻瓜                  式操作,如果更新安装程序的时候,之前的老程序还在运行这个时候如果你去提示让用户吧老程序手动退掉也不现实. 所以当遇到这种 ...

  4. linux脚本-判断进程是否存在,从而可以做预警处理..

    count=`ps -ef | grep Seeyon | grep -v "grep" | wc -l` echo $count if [ $count -gt 0 ]; the ...

  5. DOS中判断进程是否存在的方法

    这里分享的主要是通过批处理中先判断进程是否存在,然后再做出操作的实现代码,需要的朋友可以参考下   检测进程是否存在,并做出预定动作. tasklist /nh>d:\tddown~1\1.tx ...

  6. C++ 判断进程是否存在

    原文:http://blog.csdn.net/u010803748/article/details/53927977?locationNum=2&fps=1 一.判断指定程序名的进程是否存在 ...

  7. 一个电脑同时运行 64bit 和 32bit 的eclipse 如何匹配 jdk环境

    一个电脑同时运行 64bit 和 32bit   的  eclipse 如何匹配 jdk环境 1 eclipse 分 64bit 和 32bit 两种.  64bit的eclipse 只能搭配 64b ...

  8. erlang中判断进程是否存活

    一个参数的方法是已知Pid判断进程是否存活.两个参数的方法是已知节点和Pid或进程名判断进程是否存活. is_process_alive(Pid) when is_pid(Pid)->rpc:c ...

  9. 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- ...

随机推荐

  1. co & thunkify

    co 之前在generator中已经介绍过Co了 戳这里 http://www.cnblogs.com/cart55free99/p/4893498.html co一般和thunkify一起使用 能够 ...

  2. Paas

    bae sae PowerApp 还有啥???

  3. 关于LWIP---UDP

    lwip是一个轻量级的TCP/IP协议栈(Lightweight TCP/IP Stack)实现,最初是瑞士计算机科学学院Adam Dunkels编写的一个应用于无操作系统的嵌入式系统中的TCP/IP ...

  4. docker数据管理2

    3. 定义数据卷容器: 只是为了共享数据 docker run -itd -v /data/ --name centeos_testv centos bash /data/ 就是虚拟机内的目录,和宿主 ...

  5. Apache OpenOffice 与 LibreOffice 之间的抉择

    Apache OpenOffice 与 LibreOffice 之间的抉择 Apache OpenOffice和LibreOffice都 是OpenOffice.org的现代衍生产品.最近几年,几乎所 ...

  6. JavaScript代码编写尝试使用Vanilla JS 或者Jquery插件

    From Here: http://vanilla-js.com/ Vanilla JS is a fast, lightweight, cross-platform frameworkfor bui ...

  7. AndroidUI 视图动画-旋转动画效果 (RotateAnimation)

    RotateAnimation,能实现Android的视图的旋转效果,废话不多说直接上代码. 新建一个Android 项目,在activity_main.xml中添加一个按钮,然后使用Relative ...

  8. #include <QPushButton>

    类QPushButton 命令按钮 #include "mainwindow.h" #include <QApplication> int main(int argc, ...

  9. C#中各种计时器

    1.使用 Stopwatch 类 (System.Diagnostics.Stopwatch) Stopwatch 实例可以测量一个时间间隔的运行时间,也可以测量多个时间间隔的总运行时间.在典型的 S ...

  10. oracle 如何重置用户密码