using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Management; namespace _17获取MAC地址 { class Program { static void Main(string[] args) { ManagementObjectSearcher nisc = new ManagementObjectSearcher("select * from Win32_NetworkAdapterConfiguration"); foreach (ManagementObject nic in nisc.Get()) { if (Convert.ToBoolean(nic["ipEnabled"]) == true) { Console.WriteLine("{0} - {1}", nic["ServiceName"], nic["MACAddress"]); } } Console.ReadKey(); } } }