IPInterfaceProperties クラス

定義

インターネット プロトコル Version 4 (IPv4) またはインターネット プロトコル Version 6 (IPv6) をサポートしているネットワーク インターフェイスに関する情報を提供します。

public ref class IPInterfaceProperties abstract
public abstract class IPInterfaceProperties
type IPInterfaceProperties = class
Public MustInherit Class IPInterfaceProperties
継承
IPInterfaceProperties

次のコード例では、アドレス情報を表示します。

void ShowIPAddresses( IPInterfaceProperties ^ adapterProperties )
{
   IPAddressCollection ^ dnsServers = adapterProperties->DnsAddresses;
   if ( dnsServers != nullptr )
   {
      System::Collections::IEnumerator^ myEnum = dnsServers->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         IPAddressInformation ^ dns = safe_cast<IPAddressInformation ^>(myEnum->Current);
         Console::WriteLine( "  DNS Servers ............................. : {0} ({1} {2})",
            dns->Address, dns->IsTransient ? (String^)"Transient" : "", dns->IsDnsEligible ? (String^)"DNS Eligible" : "" );
      }
   }

   IPAddressInformationCollection ^ anyCast = adapterProperties->AnycastAddresses;
   if ( anyCast != nullptr )
   {
      System::Collections::IEnumerator^ myEnum1 = anyCast->GetEnumerator();
      while ( myEnum1->MoveNext() )
      {
         IPAddressInformation ^ any = safe_cast<IPAddressInformation ^>(myEnum1->Current);
         Console::WriteLine( "  Anycast Address .......................... : {0} {1} {2}", any->Address, any->IsTransient ? (String^)"Transient" : "", any->IsDnsEligible ? (String^)"DNS Eligible" : "" );
      }

      Console::WriteLine();
   }

   MulticastIPAddressInformationCollection ^ multiCast = adapterProperties->MulticastAddresses;
   if ( multiCast != nullptr )
   {
      System::Collections::IEnumerator^ myEnum2 = multiCast->GetEnumerator();
      while ( myEnum2->MoveNext() )
      {
         IPAddressInformation ^ multi = safe_cast<IPAddressInformation ^>(myEnum2->Current);
         Console::WriteLine( "  Multicast Address ....................... : {0} {1} {2}", multi->Address, multi->IsTransient ? (String^)"Transient" : "", multi->IsDnsEligible ? (String^)"DNS Eligible" : "" );
      }

      Console::WriteLine();
   }

   UnicastIPAddressInformationCollection ^ uniCast = adapterProperties->UnicastAddresses;
   if ( uniCast != nullptr )
   {
      String^ lifeTimeFormat = "dddd, MMMM dd, yyyy  hh:mm:ss tt";
      System::Collections::IEnumerator^ myEnum3 = uniCast->GetEnumerator();
      while ( myEnum3->MoveNext() )
      {
         UnicastIPAddressInformation ^ uni = safe_cast<UnicastIPAddressInformation ^>(myEnum3->Current);
         DateTime when;
         Console::WriteLine( "  Unicast Address ......................... : {0}", uni->Address );
         Console::WriteLine( "     Prefix Origin ........................ : {0}", uni->PrefixOrigin );
         Console::WriteLine( "     Suffix Origin ........................ : {0}", uni->SuffixOrigin );
         Console::WriteLine( "     Duplicate Address Detection .......... : {0}", uni->DuplicateAddressDetectionState );

         // Format the lifetimes as Sunday, February 16, 2003 11:33:44 PM
         // if en-us is the current culture.
         // Calculate the date and time at the end of the lifetimes.
         when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressValidLifetime );
         when = when.ToLocalTime();
         Console::WriteLine( "     Valid Life Time ...................... : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) );
         when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressPreferredLifetime );
         when = when.ToLocalTime();
         Console::WriteLine( "     Preferred life time .................. : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) );
         when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->DhcpLeaseLifetime );
         when = when.ToLocalTime();
         Console::WriteLine( "     DHCP Leased Life Time ................ : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) );
      }

      Console::WriteLine();
   }
}
public static void ShowIPAddresses(IPInterfaceProperties adapterProperties)
{
    IPAddressCollection dnsServers = adapterProperties.DnsAddresses;
    if (dnsServers != null)
    {
        foreach (IPAddress dns in dnsServers)
        {
            Console.WriteLine("  DNS Servers ............................. : {0}",
                dns.ToString()
           );
        }
    }
    IPAddressInformationCollection anyCast = adapterProperties.AnycastAddresses;
    if (anyCast != null)
    {
        foreach (IPAddressInformation any in anyCast)
        {
            Console.WriteLine("  Anycast Address .......................... : {0} {1} {2}",
                any.Address,
                any.IsTransient ? "Transient" : "",
                any.IsDnsEligible ? "DNS Eligible" : ""
            );
        }
        Console.WriteLine();
    }

    MulticastIPAddressInformationCollection multiCast = adapterProperties.MulticastAddresses;
    if (multiCast != null)
    {
        foreach (IPAddressInformation multi in multiCast)
        {
            Console.WriteLine("  Multicast Address ....................... : {0} {1} {2}",
                multi.Address,
                multi.IsTransient ? "Transient" : "",
                multi.IsDnsEligible ? "DNS Eligible" : ""
            );
        }
        Console.WriteLine();
    }
    UnicastIPAddressInformationCollection uniCast = adapterProperties.UnicastAddresses;
    if (uniCast != null)
    {
        string lifeTimeFormat = "dddd, MMMM dd, yyyy  hh:mm:ss tt";
        foreach (UnicastIPAddressInformation uni in uniCast)
        {
            DateTime when;

            Console.WriteLine("  Unicast Address ......................... : {0}", uni.Address);
            Console.WriteLine("     Prefix Origin ........................ : {0}", uni.PrefixOrigin);
            Console.WriteLine("     Suffix Origin ........................ : {0}", uni.SuffixOrigin);
            Console.WriteLine("     Duplicate Address Detection .......... : {0}",
                uni.DuplicateAddressDetectionState);

            // Format the lifetimes as Sunday, February 16, 2003 11:33:44 PM
            // if en-us is the current culture.

            // Calculate the date and time at the end of the lifetimes.
            when = DateTime.UtcNow + TimeSpan.FromSeconds(uni.AddressValidLifetime);
            when = when.ToLocalTime();
            Console.WriteLine("     Valid Life Time ...................... : {0}",
                when.ToString(lifeTimeFormat,System.Globalization.CultureInfo.CurrentCulture)
            );
            when = DateTime.UtcNow + TimeSpan.FromSeconds(uni.AddressPreferredLifetime);
            when = when.ToLocalTime();
            Console.WriteLine("     Preferred life time .................. : {0}",
                when.ToString(lifeTimeFormat,System.Globalization.CultureInfo.CurrentCulture)
            );

            when = DateTime.UtcNow + TimeSpan.FromSeconds(uni.DhcpLeaseLifetime);
            when = when.ToLocalTime();
            Console.WriteLine("     DHCP Leased Life Time ................ : {0}",
                when.ToString(lifeTimeFormat,System.Globalization.CultureInfo.CurrentCulture)
            );
        }
        Console.WriteLine();
    }
}

注釈

このクラスは、IPv4 または IPv6 をサポートするネットワーク インターフェイスの構成とアドレス情報へのアクセスを提供します。 このクラスのインスタンスは作成しません。これらは メソッドによって GetIPProperties 返されます。

IPv4 固有のプロパティにアクセスするには、 メソッドによって返される オブジェクトを GetIPv4Properties 使用します。 IPv6 固有のプロパティにアクセスするには、 メソッドによって返される オブジェクトを GetIPv6Properties 使用します。

コンストラクター

IPInterfaceProperties()

IPInterfaceProperties クラスの新しいインスタンスを初期化します。

プロパティ

AnycastAddresses

このインターフェイスに割り当てられているエニーキャスト IP アドレスを取得します。

DhcpServerAddresses

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

DnsAddresses

このインターフェイスのドメイン ネーム システム (DNS) サーバーのアドレスを取得します。

DnsSuffix

このインターフェイスに関連付けられているドメイン ネーム システム (DNS) サフィックスを取得します。

GatewayAddresses

このインターフェイスの IPv4 ネットワーク ゲートウェイのアドレスを取得します。

IsDnsEnabled

このインターフェイスで NetBt が DNS の名前解決を使用するように構成されているかどうかを示す Boolean 値を取得します。

IsDynamicDnsEnabled

このインターフェイスがドメイン ネーム システム (DNS) を使用して自動的に IP アドレス情報を登録するように構成されているかどうかを示す Boolean 値を取得します。

MulticastAddresses

このインターフェイスに割り当てられているマルチキャスト アドレスを取得します。

UnicastAddresses

このインターフェイスに割り当てられているユニキャスト アドレスを取得します。

WinsServersAddresses

WINS (Windows Internet Name Service) サーバーのアドレスを取得します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetIPv4Properties()

このネットワーク インターフェイスのインターネット プロトコル Version 4 (IPv4) 構成データを提供します。

GetIPv6Properties()

このネットワーク インターフェイスのインターネット プロトコル Version 6 (IPv6) 構成データを提供します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象