C#获取cpuid问题

图片描述

string GetCpuID()

{

try

{

//获取CPU序列号代码

string cpuInfo = "";//cpu序列号

ManagementClass mc = new ManagementClass("Win32_Processor");

ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)

{

cpuInfo = mo.Properties.Value.ToString();

}

moc = null;

mc = null;

return cpuInfo;

}

catch

{

return "unknow";

}

}

已引用命名空间using System.Management;

回答:

需要在“引用”中引入 System.Management 库 (DLL)

clipboard.png

回答:

看看这段代码是否符合需要:

ManagementClass mc = new ManagementClass("Win32_Processor");

ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)

{

cpu_info = mo.Properties["ProcessorId"].Value.ToString();

break;

}

以上是 C#获取cpuid问题 的全部内容, 来源链接: utcz.com/p/189563.html

回到顶部