2013-05-04 127 views
2

我要检测的运算能力的CPU(尤其是如果它是一个32/64位CPU)如何检测,如果CPU是32位还是64位

的机器在32位操作系统上运行(操作系统)我想检测这些机器是否能够安装64位操作系统。

(顺便说一句:在这一点上,我知道如何检测内核的数量...)

+0

这也许[问题](http://stackoverflow.com/questions/2017409/right-way-to-detect-cpu-architecture)可以帮助您检测CPU架构。 – ahawkthomas 2013-05-04 10:02:37

+0

看看[这里] [1]和[这里] [2],他们已经回答 [1]:http://stackoverflow.com/questions/1542213/how-to-find-的用户号码的CPU的型芯 - 经由网-C [2]:http://stackoverflow.com/questions/1817268/how-can-i-determine-programmatically-whether-on-multi-core -hyperthreading-or-mu – Solaflex 2013-05-04 10:02:48

+0

@ahawkthomas:我认为答案说明了一些关于当前安装的操作系统,而不是CPU本身。 – 2013-05-04 10:05:30

回答

2

您可以使用WMI以获取有关每个CPU更多的细节,following properties are available in the Win32_Processor class

您可以使用以下代码来获得每个属性的值:

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor"); 
ManagementObjectCollection cpus = searcher.Get() 
foreach (ManagementObject queryObj in cpus) 
{ 
    Console.WriteLine("AddressWidth : {0}", queryObj["AddressWidth"]); //On a 32-bit operating system, the value is 32 and on a 64-bit operating system it is 64. 
    Console.WriteLine("DataWidth: {0}", queryObj["DataWidth"]); //On a 32-bit processor, the value is 32 and on a 64-bit processor it is 64 
    Console.WriteLine("Architecture: {0}", queryObj["Architecture"]); //Processor architecture used by the platform 
} 

我不知道,如果AddressWidth是,你需要确定是否为CPU能够与64位操作系统或不

正确的属性
+0

嗯...那个“位”的部分是,我与正如我所提到烦心事......一:我知道如何寻找#cores。 – 2013-05-04 10:20:57

+0

因为我告诉你,你可以使用'AddressWidth'属性来获取是否如果CPU可以支持64位操作系统或没有,对不起,我接着说:NumberOfCores'作为例子在我的代码,我只是编辑它来写的'AddressWidth ' – 2013-05-04 10:31:22

+0

的'AddressWidth'表示操作系统的架构,但是你可以使用'DataWidth'属性来获取CPU架构,检查[MSDN文档(http://msdn.microsoft.com/en-us/library/窗户/桌面/ aa394373%28V = vs.85%29.aspx) – 2013-05-04 10:42:36

0

或者如果你想玩所有的WMI课程,你可以使用WMI Code Creator

我以前用过它,它帮了我很多。

相关问题