///
///获取cpu序列号
///
///
public string GetCpuInfo()
{
string strID = "";
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
strID = mo.Properties["ProcessorId"].Value.ToString();
break;
}
return strID;
}
///
/// 获取主板的编号
///
///
public string GetMainBoardID()
{
string strID = "";
ManagementClass mc = new ManagementClass("Win32_BaseBoard");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
strID = mo.Properties["SerialNumber"].Value.ToString();
break;
}
return strID;
}
///
/// 获取BIOS编号
///
///
public string GetBiosID()
{
string strID = "";
ManagementClass mc = new ManagementClass("Win32_BIOS");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
strID = mo.Properties["SerialNumber"].Value.ToString();
break;
}
return strID;
}
///
/// 获取网卡硬件地址
///
///
public string GetMacAddress()
{
string MoAddress = "0000000000";
using (ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"))
{
ManagementObjectCollection moc2 = mc.GetInstances();
foreach (ManagementObject mo in moc2)
{
if ((bool)mo["IPEnabled"] == true)
{
MoAddress = mo["MacAddress"].ToString();
MoAddress = MoAddress.Replace(":", "");
}
mo.Dispose();
}
}
return MoAddress.ToString();
} 标签:电脑硬件,ManagementClass,strID,string,mc,mo,信息,获取,moc From: https://www.cnblogs.com/qiutian-hao/p/18086585