• C/C++ 判断进程32位还是64位


    这里提供两段代码,可用于判断进程是32位还是64位。

    代码1

    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;
    }
    

    代码2

    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;
    }
    
  • 相关阅读:
    【微服务架构】SpringCloud之Ribbon
    SpringCloud之Eureka(注册中心集群篇)
    Eureka简介
    两行代码 搞定计数
    HBase详细概述
    电商项目介绍---说的很好
    面试:----Nginx的一理解
    redis介绍
    Linux操作系统介绍
    什么是Solr
  • 原文地址:https://www.cnblogs.com/LyShark/p/15019540.html
Copyright © 2020-2023  润新知