C#获取网卡硬件地址。。。mac地址
private static string GetMAC() { 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(); mo.Dispose();//释放资源 break; } } moc = null; mc = null; return mac; } catch { return "unknow"; } }