using System.Management;

/// <summary>
/// 获取MAC地址
/// </summary>
/// <returns></returns>
public string GetNetCardMacAddress()
{
ManagementClass mc;
ManagementObjectCollection moc;
mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
moc = mc.GetInstances();
string str = "";
foreach(ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
str = mo["MacAddress"].ToString();

}
return str;
}

/// <summary>
/// C盘序列号
/// </summary>
/// <returns></returns>
public string GetDiskVolumeSerialNumber()
{
ManagementObject disk;
disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
}


1条评论

  1. 谢谢分享

发表评论

评论也有版权!