次の方法で共有


IPInterfaceProperties.DhcpServerAddresses プロパティ

定義

このインターフェイスの DHCP (Dynamic Host Configuration Protocol) サーバーのアドレスを取得します。

public:
 abstract property System::Net::NetworkInformation::IPAddressCollection ^ DhcpServerAddresses { System::Net::NetworkInformation::IPAddressCollection ^ get(); };
public abstract System.Net.NetworkInformation.IPAddressCollection DhcpServerAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("freebsd")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("osx")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public abstract System.Net.NetworkInformation.IPAddressCollection DhcpServerAddresses { get; }
member this.DhcpServerAddresses : System.Net.NetworkInformation.IPAddressCollection
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("freebsd")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("osx")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
member this.DhcpServerAddresses : System.Net.NetworkInformation.IPAddressCollection
Public MustOverride ReadOnly Property DhcpServerAddresses As IPAddressCollection

プロパティ値

DHCP サーバーのアドレス情報を格納している IPAddressCollection。DHCP サーバーが見つからない場合は空の配列。

属性

次のコード例では、ローカル コンピューター上のネットワーク インターフェイスの DHCP アドレス情報を表示します。

void DisplayDhcpServerAddresses()
{
   Console::WriteLine( "DHCP Servers" );
   array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum19 = adapters->GetEnumerator();
   while ( myEnum19->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum19->Current);
      IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
      IPAddressCollection ^ addresses = adapterProperties->DhcpServerAddresses;
      if ( addresses->Count > 0 )
      {
         Console::WriteLine( adapter->Description );
         System::Collections::IEnumerator^ myEnum20 = addresses->GetEnumerator();
         while ( myEnum20->MoveNext() )
         {
            IPAddress^ address = safe_cast<IPAddress^>(myEnum20->Current);
            Console::WriteLine( "  Dhcp Address ............................ : {0}", 
               address );
         }
         Console::WriteLine();
      }
   }
}
public static void DisplayDhcpServerAddresses()
{
    Console.WriteLine("DHCP Servers");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {

        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        IPAddressCollection addresses = adapterProperties.DhcpServerAddresses;
        if (addresses.Count >0)
        {
            Console.WriteLine(adapter.Description);
            foreach (IPAddress address in addresses)
            {
                Console.WriteLine("  Dhcp Address ............................ : {0}",
                    address.ToString());
            }
            Console.WriteLine();
        }
    }
}
Public Shared Sub DisplayDhcpServerAddresses() 
    Console.WriteLine("DHCP Servers")
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        
        Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
        Dim addresses As IPAddressCollection = adapterProperties.DhcpServerAddresses
        If addresses.Count > 0 Then
            Console.WriteLine(adapter.Description)
            Dim address As IPAddress
            For Each address In  addresses
                Console.WriteLine("  Dhcp Address ............................ : {0}", address.ToString())
            Next address
            Console.WriteLine()
        End If
    Next adapter

End Sub

注釈

動的ホスト構成プロトコル (DHCP) を使用すると、コンピューターは静的 (固定) ネットワーク アドレスを使用するのではなく、DHCP サーバーからネットワーク アドレスを取得できます。 DHCP サーバーはアドレスを永続的に割り当てません。代わりに、コンピューターで使用可能なアドレスの 1 つを一時的に使用します。

適用対象