在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
效果: 说明:获取本局域网的MAC地址(非本机的MAC地址) 代码: 1 /// <summary> 2 /// 获取网卡物理地址 3 /// </summary> 4 /// <returns></returns> 5 public static string getMAC() 6 { 7 string madAddr = null; 8 ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); 9 ManagementObjectCollection moc2 = mc.GetInstances(); 10 foreach (ManagementObject mo in moc2) 11 { 12 if (Convert.ToBoolean(mo["IPEnabled"]) == true) 13 { 14 madAddr = mo["MacAddress"].ToString(); 15 madAddr = madAddr.Replace(':', '-'); 16 } 17 mo.Dispose(); 18 } 19 return madAddr; 20 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论