/// <summary>/// 机器码
/// </summary>
public class MachineCode
{
///<summary>
/// 获取cpu序列号
///</summary>
///<returns> string </returns>
public string GetCpuInfo()
{
string cpuInfo = " ";
using (ManagementClass cimobject = new ManagementClass("Win32_Processor"))
{
ManagementObjectCollection moc = cimobject.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
mo.Dispose();
}
}
return cpuInfo.ToString();
}
///<summary>
/// 获取硬盘ID
///</summary>
///<returns> string </returns>
public string GetHDid()
{
string HDid = " ";
using (ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive"))
{
ManagementObjectCollection moc1 = cimobject1.GetInstances();
foreach (ManagementObject mo in moc1)
{
HDid = (string)mo.Properties["Model"].Value;
mo.Dispose();
}
}
return HDid.ToString();
}
///<summary>
/// 获取网卡硬件地址
///</summary>
///<returns> string </returns>
public string GetMoAddress()
{
string MoAddress = " ";
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();
mo.Dispose();
}
}
return MoAddress.ToString();
}
}
相关文章
- 10-04获取CPU序列号、网卡MAC地址、硬盘序列号
- 10-04C#获取本机和其它计算机物理网卡地址(MAC)
- 10-04C# 获取网卡信息
- 10-04DSAPI 获取实时统计信息CPU/内存/硬盘/网络
- 10-04C# 获取计算机信息
- 10-04windows平台下 c++获取 系统版本 网卡 内存 CPU 硬盘 显卡信息
- 10-04C# 获取本机CPU序列号,MAC地址,硬盘ID,本机IP地址,计算机名,物理内存,PC类型
- 10-04windows平台下 c++获取 系统版本 网卡 内存 CPU 硬盘 显卡信息<转>
- 10-04C#获取硬盘空间信息
- 10-04C#获取cpu序列号 硬盘ID 网卡硬地址以及操作注册表 .