获取本机MAC地址

ManagementClass objCustom1 = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection objCustom2 = objCustom1.GetInstances();
string strMac = string.Empty;
foreach (ManagementObject objCustom3 in objCustom2)
{
if ((bool)objCustom3["IPEnabled"] == true)
{
strMac = objCustom3["MacAddress"].ToString().Replace(':','-');
}
}

MessageBox.Show(strMac);
原文地址:https://www.cnblogs.com/topcoder/p/2908942.html