服务器上面的板子可能有多个cpu,但是GetSystemInfo得到的是某个cpu内核的数量啊。我怎么得到cpu数量呢?

解决方案 »

  1.   

    http://hi.baidu.com/_ynbg/blog/item/14ec57ae8bba21c17dd92a35.html
      

  2.   

    #include "stdafx.h"
    #include <Windows.h>int _tmain(int argc, _TCHAR* argv[])

    SYSTEM_INFO SystemInfo;GetSystemInfo(&SystemInfo);
    int i;i= SystemInfo.dwNumberOfProcessors;
    printf("CPU个数=%d\n",i);return 0;
    }
      

  3.   


    谢谢,但是我感觉,GetSystemInfo和GetNativeSystemInfo这两个函数没有什么不同的地方啊
      

  4.   

    无论是GetSystemInfo还是GetNativeSystemInfo,返回的都是cpu内核的个数。
      

  5.   

    多个cpu的情况没遇到过,不过只能得到内核数量的,这个结果应该和设备管理器里面看到的是一样的。