//获取cpu序列号
string cpuInfo = "";
ManagementClass cimobject = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = cimobject.GetInstances();
foreach(ManagementObject mo in moc)
{
if(mo.Properties["ProcessorId"].Value != null)
cpuInfo += mo.Properties["ProcessorId"].Value.ToString();
}
result += cpuInfo;
//获取硬盘ID
string HDid = "";
ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
ManagementObjectCollection moc1 = cimobject1.GetInstances();
foreach(ManagementObject mo in moc1)
{
if(mo.Properties["Model"].Value != null)
HDid += (string)mo.Properties["Model"].Value.ToString();
}
result += HDid;
//获取网卡硬件地址
string MACAddress = "";
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc2 = mc.GetInstances();
foreach(ManagementObject mo in moc2)
{
if((bool)mo["IPEnabled"] == true && mo["MacAddress"] != null)
MACAddress += mo["MacAddress"].ToString();
mo.Dispose();
}
result += MACAddress;