다음을 통해 공유


NetworkInterface.GetAllNetworkInterfaces 메서드

정의

로컬 컴퓨터의 네트워크 인터페이스를 설명하는 개체를 반환합니다.

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()

반환

사용 가능한 네트워크 인터페이스를 설명하는 개체가 들어 있는 NetworkInterface 배열이거나, 발견된 인터페이스가 없는 경우 빈 배열입니다.

특성

예외

Windows 시스템 함수 호출이 실패한 경우

예제

다음 코드 예제에서는 로컬 컴퓨터의 네트워크 어댑터에 대 한 DNS (Domain Name Service) 구성 정보를 표시 합니다.

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

설명

컴퓨터의 네트워크 인터페이스는 네트워크 연결을 제공합니다. 네트워크 인터페이스를 네트워크 어댑터라고도 합니다.

적용 대상