首页 技术 正文
技术 2022年11月19日
0 收藏 576 点赞 3,737 浏览 1529 个字

1、IsWow64Process

确定指定进程是否运行在64位操作系统的32环境(Wow64)下。语法

BOOL WINAPI IsWow64Process(
  __in HANDLE hProcess,
  __out PBOOL Wow64Process
  );

参数  hProcess    进程句柄。该句柄必须具有PROCESS_QUERY_INFORMATION 或者 PROCESS_QUERY_LIMITED_INFORMATION 访问权限  Wow64Process    指向一个bool值,    如果该进程是32位进程,运行在64操作系统下,该值为true,否则为false。    如果该进程是一个64位应用程序,运行在64位系统上,该值也被设置为false。  返回值    如果函数成功返回值为非零值。    如果该函数失败,则返回值为零。要获取扩展的错误的信息,请调用GetLastError .  微软的例子:c++ 判断是64还是32位系统

  #include <windows.h>
  #include <tchar.h>
  typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
  LPFN_ISWOW64PROCESS fnIsWow64Process;
  BOOL IsWow64()
  {
    BOOL bIsWow64 = FALSE;
    //IsWow64Process is not available on all supported versions of Windows.
    //Use GetModuleHandle to get a handle to the DLL that contains the function
    //and GetProcAddress to get a pointer to the function if available.
    fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
    GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
    if(NULL != fnIsWow64Process)
    {
      if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
      {
        //handle error
      }
    }
    return bIsWow64;
  }
  int main( void )
  {
    if(IsWow64())
      _tprintf(TEXT("The process is running under WOW64.\n"));
    else
      _tprintf(TEXT("The process is not running under WOW64.\n"));
    return 0;
  }

c++ 判断是64还是32位系统

  注意:使用此函数判断操作系统是32位还是64位并不合适,勉强要用的话,可以指向一个32位进程。

2、比较合适的做法是:

c++ 判断是64还是32位系统

  BOOL Is64bitSystem()
  {
    SYSTEM_INFO si;
    GetNativeSystemInfo(&si);
    if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
            si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 )
      return TRUE;
    else
      return FALSE;
  }

c++ 判断是64还是32位系统

下一篇: redis 在linux安装
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,084
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,559
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,408
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,181
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,818
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,901