◆◇◆◇◆◇◆ CPU ID 究竟是什么?郁闷中。同时测试,欢迎参与。
原以为通过 WMI 获取的 CPU ID,对于每台电脑的 CPU 都不同的,然而发现不是这么一回事。
譬如,我的电脑 CPU ID 为“0383F9FF000006B1”,可很多赛扬 CPU 的 ID 都是这样的。真是大失所望。
我真不知道该如何来区分不同的电脑了。
希望各位朋友能在你的电脑运行一下以下代码,然后回帖告诉我测试结果的 CPU ID 是多少。谢谢了。
using System;
using System.Management;
namespace ProcessorId
{
public class Test
{
static void Main()
{
Console.WriteLine("My CPU's Id : " + GetCpuId());
Console.Read();
}
public static string GetCpuId()
{
ManagementObjectSearcher wmiSearcher = new ManagementObjectSearcher();
wmiSearcher.Query = new SelectQuery(
"Win32_Processor",
"",
new string[]{"ProcessorID"}
);
ManagementObjectCollection myCollection = wmiSearcher.Get();
ManagementObjectCollection.ManagementObjectEnumerator em =
myCollection.GetEnumerator();
em.MoveNext();
ManagementBaseObject mo = em.Current;
string cpuid = mo.Properties["ProcessorID"].Value.ToString().Trim();
return cpuid;
}
}
}