void GetSystemInfo(
  LPSYSTEM_INFO lpSystemInfo
);
typedef struct _SYSTEM_INFO {  union {    DWORD dwOemId;    struct {      WORD wProcessorArchitecture;      WORD wReserved;    };  };  DWORD dwPageSize;  LPVOID lpMinimumApplicationAddress;  LPVOID lpMaximumApplicationAddress;  DWORD_PTR dwActiveProcessorMask;  DWORD dwNumberOfProcessors;  DWORD dwProcessorType;  DWORD dwAllocationGranularity;  WORD wProcessorLevel;  WORD wProcessorRevision;
} SYSTEM_INFO;
Members
dwNumberOfProcessors 
Number of processors in the system. 

解决方案 »

  1.   

    同意楼上
    DWORD GetNumberOfProcessors()
    {
    SYSTEM_INFO SysInfo; GetSystemInfo(&SysInfo);
    return SysInfo.dwNumberOfProcessors;
    }
      

  2.   


    NtQuerySystemInformation(1,&SYSTEM_PROCESSOR_INFORMATION,sizeof(SYSTEM_PROCESSOR_INFORMATION),&dwLen);大致如此
    此函数在ntdll.dll内
      

  3.   

    NtQuerySystemInformation
    [NtQuerySystemInformation is available for use in Windows 2000 and Windows XP. It may be altered or unavailable in subsequent versions. Applications should use the alternate functions listed in this topic.]
      

  4.   

    我直接使用SETUPDI 函数查找硬件也可以得到CPU的个数,但是我发现,其实这和计算机装的操作系统有关系,比如有的盗版系统装完就显示是双核的(实际上是单核),那你使用某些函数或者方法获取的时候也是显示双核的.
      

  5.   

    GetSystemInfo   ,看MSDN的解释