簡介
using system;
using system
using system
namespace hardware
{
/// <summary>
/// hardware_mac 的摘要說明
/// </summary>
public class hardwareinfo
{
//取機器名
public string gethostname()
{
return
}
//取cpu編號
public string getcpuid()
{
try
{
managementclass mc = new managementclass(
managementobjectcollection moc = mc
string strcpuid = null ;
foreach( managementobject mo in moc )
{
strcpuid = mo
break;
}
return strcpuid;
}
catch
{
return
}
}//end method
//獲取cpu序列號
public string getcpuid
{
try
{
System
string tmpUint
foreach(ManagementObject WmiObj in Wmi
{
tmpUint
}
this
this
}
catch(Exception ex
{
throw new Exception(ex
}
}
//取第一塊硬盤編號
public string getharddiskid()
{
try
{
managementobjectsearcher searcher = new managementobjectsearcher(
string strharddiskid = null ;
foreach(managementobject mo in searcher
{
strharddiskid = mo[
break;
}
return strharddiskid ;
}
catch
{
return
}
}//end
//獲取磁盤序列號
public string getharddiskid
{
try
{
System
System
foreach(ManagementObject cmicWmiObj in cmicWmi
{
tmpUint
}
this
this
}
catch(Exception ex
{
throw new Exception(ex
}
}
/// <summary>
/// 獲取硬盤ID
/// </summary>
/// <returns> string </returns>
public string GetHDid()
{
string HDid =
using (ManagementClass cimobject
{
ManagementObjectCollection moc
foreach (ManagementObject mo in moc
{
HDid = (string)mo
mo
}
}
return HDid
}
/// <summary>
/// 獲取網卡硬件地址
/// </summary>
/// <returns> string </returns>
public string GetMoAddress()
{
string MoAddress =
using (ManagementClass mc = new ManagementClass(
{
ManagementObjectCollection moc
foreach (ManagementObject mo in moc
{
if ((bool)mo[
MoAddress = mo[
mo
}
}
return MoAddress
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13763.html