MFC-GetNativeSystemInfo获取当前CPU信息

 

复制代码
    CString str;

    SYSTEM_INFO lpSystemInfo;
    GetNativeSystemInfo(&lpSystemInfo);//获取当前CPU信息
    /*
    在一个64位的应用中调用此函数,那它等效于GetSystemInfo

    */

    WORD w = lpSystemInfo.wProcessorArchitecture; //处理器的体系结构
    /*
    lpSystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64    操作系统架构: X64(AMD or Intel)
    lpSystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM      操作系统架构: AMD
    lpSystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64     操作系统架构: Intel 服务器
    lpSystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL    操作系统架构: X86

    PROCESSOR_ARCHITECTURE_IA64 || PROCESSOR_ARCHITECTURE_AMD64   表示64位系统
    
    */
    str.Format(_T("w=%d\r\n"), w);
    ::OutputDebugString(str);

    WORD w1 = lpSystemInfo.dwPageSize;//指定页面的大小和页面保护和委托的颗粒。这是被 VirtualAlloc 函数使用的页大小
    //w1=4096    
    str.Format(_T("w1=%d\r\n"), w1);
    ::OutputDebugString(str);

    LPVOID p = lpSystemInfo.lpMinimumApplicationAddress;//指向应用程序和动态链接库(DLL)可以访问的最低内存地址

    LPVOID p1 = lpSystemInfo.lpMaximumApplicationAddress;//指向应用程序和动态链接库(DLL)可以访问的最高内存地址

    DWORD_PTR ptr = lpSystemInfo.dwActiveProcessorMask;
    /*指定一个用来代表这个系统中装配了的中央处理器的掩码。二进制0位是处理器0;31位是处理器31
    ptr=15
    【15的二进制就是1111,所以本机有4个CPU】
    */
    str.Format(_T("ptr=%d\r\n"), ptr);
    ::OutputDebugString(str);

    DWORD w2 = lpSystemInfo.dwNumberOfProcessors;//指定系统中的处理器的数目
    str.Format(_T("w2=%d\r\n"), w2);
    ::OutputDebugString(str);

    DWORD w3 = lpSystemInfo.dwProcessorType;//中央处理器的类型
    str.Format(_T("w3=%d\r\n"), w3);
    ::OutputDebugString(str);

    DWORD w4 = lpSystemInfo.dwAllocationGranularity;//虚拟内存空间的粒度
    //w4=65536
    str.Format(_T("w4=%d\r\n"), w4);
    ::OutputDebugString(str);

    WORD w5 = lpSystemInfo.wProcessorLevel;//处理器等级
    //w5=6   i7处理器
    str.Format(_T("w5=%d\r\n"), w5);
    ::OutputDebugString(str);

    WORD w6 = lpSystemInfo.wProcessorRevision;//处理器版本
    //w6=14857
    str.Format(_T("w6=%d\r\n"), w6);
    ::OutputDebugString(str);
复制代码

 

 

 

 

 

 

posted @   天子骄龙  阅读(409)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示