NetworkInterface
класс в System.Net.NetworkInformation
пространство имен должно быть полезной для Вас (более конкретно, то GetAllNetworkInterfaces
метод. Пример показан на связанной странице MSDN, которая демонстрирует, как получить тип, адрес, рабочее состояние, а также другие информация о каждом сетевом интерфейсе
Уменьшенная версия примера MSDN:.
public static void ShowNetworkInterfaces()
{
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();
Console.WriteLine();
Console.WriteLine(adapter.Description);
Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'='));
Console.WriteLine(" Interface type .......................... : {0}", adapter.NetworkInterfaceType);
Console.WriteLine(" Physical Address ........................ : {0}",
adapter.GetPhysicalAddress().ToString());
Console.WriteLine(" Operational status ...................... : {0}",
adapter.OperationalStatus);
Console.WriteLine();
}
}
ОК, но на основе этих свойств, как вы можете сказать, если сетевой интерфейс 3G/EDGE/GPRS Я пытался подключить? 3G-модем на мой компьютер, NetworkInterfaceType - это «Ppp», который не говорит, nection. –