C# 获取CPU序列号、硬盘卷标号
获取硬盘卷标号
public string GetDiskVolumeSerialNumber()
{
ManagementClass mc = new ManagementClass("win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
}
获取CUP序列号
public string GetCpu()
{
string strCpu = null;
ManagementClass myCpu = new ManagementClass("win32_Processor");
ManagementObjectCollection myCpuCollection = myCpu.GetInstances();
foreach (ManagementObject myObject in myCpuCollection)
{
strCpu = myObject.Properties["Processorid"].Value.ToString();
}
return strCpu;
}
//网络素材仅限收藏 方便学习