NetworkInterface.GetAllNetworkInterfaces Metoda

Definice

Vrátí objekty, které popisují síťová rozhraní v místním počítači.

public:
 static cli::array <System::Net::NetworkInformation::NetworkInterface ^> ^ GetAllNetworkInterfaces();
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces ();
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces ();
static member GetAllNetworkInterfaces : unit -> System.Net.NetworkInformation.NetworkInterface[]
[<System.Runtime.Versioning.UnsupportedOSPlatform("illumos")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("solaris")>]
static member GetAllNetworkInterfaces : unit -> System.Net.NetworkInformation.NetworkInterface[]
Public Shared Function GetAllNetworkInterfaces () As NetworkInterface()

Návraty

Pole NetworkInterface obsahující objekty, které popisují dostupná síťová rozhraní, nebo prázdné pole, pokud nejsou zjištěna žádná rozhraní.

Atributy

Výjimky

Volání funkce systému Windows se nezdařilo.

Příklady

Následující příklad kódu zobrazí informace o konfiguraci dns (Domain Name Service) pro síťové adaptéry místního počítače.

void DisplayDnsConfiguration()
{
   array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum10 = adapters->GetEnumerator();
   while ( myEnum10->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum10->Current);
      IPInterfaceProperties ^ properties = adapter->GetIPProperties();
      Console::WriteLine( adapter->Description );
      Console::WriteLine( "  DNS suffix................................. :{0}", 
         properties->DnsSuffix );
      Console::WriteLine( "  DNS enabled ............................. : {0}", 
         properties->IsDnsEnabled );
      Console::WriteLine( "  Dynamically configured DNS .............. : {0}", 
         properties->IsDynamicDnsEnabled );
   }
}
public static void DisplayDnsConfiguration()
{
    NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties properties = adapter.GetIPProperties();
        Console.WriteLine(adapter.Description);
        Console.WriteLine("  DNS suffix .............................. : {0}",
            properties.DnsSuffix);
        Console.WriteLine("  DNS enabled ............................. : {0}",
            properties.IsDnsEnabled);
        Console.WriteLine("  Dynamically configured DNS .............. : {0}",
            properties.IsDynamicDnsEnabled);
    }
    Console.WriteLine();
}
Public Shared Sub DisplayDnsConfiguration() 
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
        Console.WriteLine(adapter.Description)
        Console.WriteLine("  DNS suffix................................. :{0}", properties.DnsSuffix)
        Console.WriteLine("  DNS enabled ............................. : {0}", properties.IsDnsEnabled)
        Console.WriteLine("  Dynamically configured DNS .............. : {0}", properties.IsDynamicDnsEnabled)
    Next adapter

End Sub

Poznámky

Síťová rozhraní v počítači poskytují síťové připojení. Síťová rozhraní se také označují jako síťové adaptéry.

Platí pro