首页 > 代码库 > 获取网卡地址信息

获取网卡地址信息

        public string GetMacAddress()        {            try            {                string mac = "";                ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");                ManagementObjectCollection moc = mc.GetInstances();                foreach (ManagementObject mo in moc)                {                    if ((bool)mo["IPEnabled"] == true)                    {                        mac = mo["MacAddress"].ToString();                        break;                    }                }                moc = null;                mc = null;                return mac;            }            catch            {                return "unknow";            }        } 

 

获取网卡地址信息