📜  c# 获取 cpu id - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:14.650000             🧑  作者: Mango

代码示例2
string cpuID = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)
{
 if (cpuID == "")
 {
      //Remark gets only the first CPU ID
      cpuID = mo.Properties["processorID"].Value.ToString();

 }
}
return cpuID;