代码如下:
1 //获得网卡序列号 2 //MAc地址 http://www.cnblogs.com/sosoft/ 3 public string GetMoAddress() 4 { 5 string MoAddress = " "; 6 ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); 7 ManagementObjectCollection moc2 = mc.GetInstances(); 8 foreach (ManagementObject mo in moc2) 9 { 10 if ((bool)mo["IPEnabled"] == true) 11 MoAddress = mo["MacAddress"].ToString(); 12 mo.Dispose(); 13 } 14 return MoAddress.ToString(); 15 }