获取 XP 64 位系统上的核心数
Hej,
我写了一个函数,应该可以给出 Windows 系统的核心数量。它适用于除 XP 64 位之外的所有系统。以下是我获取信息的方式:
$objWMIItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor")
If (0 == IsObj($objWMIItems)) Then
;~ errorhandling
Else
For $objElement In $objWMIItems
$nCoreNumber = $objElement.NumberOfCores
Next
关于“NumberOfCores”,Microsoft 的 MSDN 页面告诉我“Windows Server 2003、Windows XP 和 Windows 2000:此属性不可用”。我在某处读到,安装 SP3 是可能的。我想这是真的,因为它在 XP 32 位系统上就是这样工作的。但是XP 64没有SP3...
还有其他方法获取信息吗?
谢谢
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.NumberOfCores
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为读取 NUMBER_OF_PROCESSORS 环境变量是最简单的。
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: