使用WMI来获取CPU序列号
//返回的是一个数组,可能存在多个CPU
using System;
using System.Management;
using System.Collections;
public ArrayList GetCpuID()
{
ArrayList al=new ArrayList();
try
{
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach( ManagementObject mo in moc )
{
al.Add(mo.Properties["ProcessorId"].Value.ToString());
}
return al;
}
catch()
{
return null;
}
}