3、 /// 應用程式的主進入點。 /// [STAThread] private static void Main(string[] args) { GetMACByWMI(); IPAddress[] ips = GetLocalIP(); foreach (IPAddress ip in ips) { C
4、onsole.WriteLine(GetMacByARP(ip.ToString())); string mac = GetRemoteMacByNetBIOS(ip.ToString()); if ( mac.Length != 0 ) Console.WriteLine(mac); else Console.WriteLine("Fa
5、il to get MACAddress by NetBIOS"); GetMACBySNMP(ip.ToString(),"yourGroupName@yourVlanNumber"); } Console.ReadLine(); } By WMI#region By WMI public static void GetMACByWMI() { st
6、ring query = "select MACAddress from Win32_NetworkAdapterConfiguration where IPEnabled='TRUE'"; ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); ManagementObjectCollection collection = searcher.Get();
7、 foreach (ManagementObject mo in collection) { string mac = mo["MACAddress"].ToString(); Console.WriteLine(" Network card MAC Address is :{0}", mac); } } #endregion By ARP#regi