开发者

Get number of cores on a XP 64 bit system

开发者 https://www.devze.com 2023-03-24 06:45 出处:网络
Hej, I wrote a function that should give me the number of cores of a windows system. It works on all systems except XP 64 bit. Here\'s the way I get the information:

Hej,

I wrote a function that should give me the number of cores of a windows system. It works on all systems except XP 64 bit. Here's the way I get the information:

$objWMIItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor")
If (0 == IsObj($objWMIItems)) Then
       ;~ errorhandling
Else
For $objElement In $objWMIItems
    $nCoreNumber = $objElement.Number开发者_开发知识库OfCores
Next

Regarding "NumberOfCores", Microsofts MSDN page tells me "Windows Server 2003, Windows XP, and Windows 2000: This property is not available". Somewhere I read, it is possible with having SP3 installed. I suppose that's true, because it works that way on XP 32 bit systems. But there is no SP3 for XP 64...

Is there another way to get the information?

Thanks


I think it's easiest to read the NUMBER_OF_PROCESSORS environment variable.


Do you want "cores" or "number of logical processors including hyperthreading"? (In other words, do you want to count hyperthreading as a "core")?

In any case, copying my answer from a similar question a while back:

If you actually need to distinguish between actual cores, chips, and logical processors, the API to call is GetLogicalProcessInformation

GetSystemInfo if just want to know how many logical processors on a machine (with no differentiation for hyperthreading.).

0

精彩评论

暂无评论...
验证码 换一张
取 消