using System;
using System.Runtime.InteropServices;
using System.Management;
namespace Hardware
{
/// <summary>
/// Hardware_Mac 的摘要说明。
/// </summary>
public class HardwareInfo
{
//取机器名
public string GetHostName()
{
return System.Net.Dns.GetHostName();
}
//取CPU编号
public String GetCpuID()
{
try
{
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
String strCpuID = null ;
foreach( ManagementObject mo in moc )
{
strCpuID = mo.Properties["ProcessorId"].Value.ToString();
break;
}
return strCpuID;
}
catch
{
return "";
}
}//end method
//取第一块硬盘编号
public String GetHardDiskID()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
String strHardDiskID = null ;
foreach(ManagementObject mo in searcher.Get())
{
strHardDiskID = mo["SerialNumber"].ToString().Trim();
break;
}
return strHardDiskID ;
}
catch
{