获取系统CPU 个数

来源:互联网 发布:数据挖掘技术dm致力于 编辑:程序博客网 时间:2024/05/17 22:08

typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
DWORD GetNumberOfProcessors()
{
SYSTEM_INFO si;
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.


PGNSI pfnGNSI = (PGNSI) GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetNativeSystemInfo");
if(pfnGNSI)
{
pfnGNSI(&si);
}
else
{
GetSystemInfo(&si);
}
return si.dwNumberOfProcessors;
}

原创粉丝点击