using System.Net.NetworkInformation; . . . IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); Console.WriteLine("Interface information for {0}.{1} ", computerProperties.HostName, computerProperties.DomainName); if (nics == null || nics.Length < 1) { Console.WriteLine(" No network interfaces found."); return; } Console.WriteLine(" Number of interfaces .................... : {0}", nics.Length); foreach (NetworkInterface adapter in nics) { IPInterfaceProperties properties = adapter.GetIPProperties(); // .GetIPInterfaceProperties(); Console.WriteLine(); Console.WriteLine(adapter.Description); Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length, '=')); Console.WriteLine(" Interface type .......................... : {0}", adapter.NetworkInterfaceType); Console.Write(" Physical address ........................ : "); PhysicalAddress address = adapter.GetPhysicalAddress(); byte[] bytes = address.GetAddressBytes(); for (int i = 0; i < bytes.Length; i++) { // Display the physical address in hexadecimal. Console.Write("{0}", bytes[i].ToString("X2")); // Insert a hyphen after each byte, unless we are at the end of the // address. if (i != bytes.Length - 1) { Console.Write("-"); } } Console.WriteLine(); }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.