1.获取CPU序列号
.net c# 通过 ManagementObjectSearcher 类,查询 Win32_Processor 对应的ProcessorId 值
/// <summary>
/// 获取CPU序列号
/// </summary>
/// <returns></returns>
public string GetCPUSerialNumber()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * From Win32_Processor");
string sCPUSerialNumber = "";
foreach (ManagementObject mo in searcher.Get())
{
sCPUSerialNumber = mo["ProcessorId"].ToString().Trim();
}
return sCPUSerialNumber;
}
catch
{
return "";
}
}
2.获得CPU编号
.net c# 通过 ManagementClass 类,查询 Win32_Processor ,获取ManagementObjectCollection对应的ProcessorId 值
/// <summary>
/// 获得CPU编号
/// </summary>
public string GetCPUID()
{
string cpuid = "";
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuid = mo.Properties["ProcessorId"].Value.ToString();
}
return cpuid;
}
3.获得CPU版本信息
通过 ManagementObjectSearcher 类,查询 Win32_Processor ,获取Version对应的值
/// <summary>
/// CPU版本信息
/// </summary>
public string GetCPUVersion()
{
string st = "";
ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_Processor");
foreach (ManagementObject mo in mos.Get())
{
st = mo["Version"].ToString();
}
return st;
}
4. 获取CPU名称信息
通过 ManagementObjectSearcher 类,查询 Win32_Processor ,获取Name对应的值
/// <summary>
/// CPU名称信息
/// </summary>
public string GetCPUName()
{
string st = "";
ManagementObjectSearcher driveID = new ManagementObjectSearcher("Select * from Win32_Processor");
foreach (ManagementObject mo in driveID.Get())
{
st = mo["Name"].ToString();
}
return st;
}
5.获取CPU制造厂商
通过 ManagementObjectSearcher 类,查询 Win32_Processor ,获取Manufacturer对应的值
/// <summary>
/// CPU制造厂商
/// </summary>
public string GetCPUManufacturer()
{
string st = "";
ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * from Win32_Processor");
foreach (ManagementObject mo in mos.Get())
{
st = mo["Manufacturer"].ToString();
}
return st;
}
运行结果: