日期:2014-05-17 浏览次数:20927 次
/// <summary>
/// 获取硬盘卷标号
/// </summary>
/// <returns></returns>
public string GetDiskVolumeSerialNumber()
{
ManagementClass mc = new ManagementClass("win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
}
/// <summary>
/// 获取CPU序列号
/// </summary>
/// <returns></returns>
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;
}