日期:2014-03-06  浏览次数:20489 次

using System.Management;


获取网卡地址 MAC



public string GetMacAddress()
{
ManagementClass adapters = new ManagementClass("Win32_NetworkAdapterConfiguration");
string MACAddress = "unknown";
foreach (ManagementObject adapter in adapters.GetInstances())
{
if((bool)adapter["IPEnabled"] == true)
{
MACAddress = adapter.Properties["MACAddress"].Value.ToString();
break;
}
}
return MACAddress;
}