IPInterfaceProperties Třída

Definice

Poskytuje informace o síťových rozhraních, které podporují protokol IPv4 (Internet Protocol verze 4) nebo protokol IPv6 (Internet Protocol verze 6).

public ref class IPInterfaceProperties abstract
public abstract class IPInterfaceProperties
type IPInterfaceProperties = class
Public MustInherit Class IPInterfaceProperties
Dědičnost
IPInterfaceProperties

Příklady

Následující příklad kódu zobrazí informace o adrese.

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

Poznámky

Tato třída poskytuje přístup k informacím o konfiguraci a adresách pro síťová rozhraní, která podporují protokolY IPv4 nebo IPv6. Nevytvoříte instance této třídy; Vrátí je GetIPProperties metoda .

Pokud chcete získat přístup k vlastnostem specifickým pro IPv4, použijte objekt vrácený metodou GetIPv4Properties . Pokud chcete získat přístup k vlastnostem specifickým pro IPv6, použijte objekt vrácený metodou GetIPv6Properties .

Konstruktory

IPInterfaceProperties()

Inicializuje novou instanci IPInterfaceProperties třídy .

Vlastnosti

AnycastAddresses

Získá ip adresy všesměrového vysílání přiřazené k tomuto rozhraní.

DhcpServerAddresses

Získá adresy serverů DHCP (Dynamic Host Configuration Protocol) pro toto rozhraní.

DnsAddresses

Získá adresy serverů DNS (Domain Name System) pro toto rozhraní.

DnsSuffix

Získá příponu DNS (Domain Name System) přidruženou k tomuto rozhraní.

GatewayAddresses

Získá adresy brány sítě IPv4 pro toto rozhraní.

IsDnsEnabled

Boolean Získá hodnotu, která označuje, zda NetBt je nakonfigurován pro použití překlad názvů DNS v tomto rozhraní.

IsDynamicDnsEnabled

Boolean Získá hodnotu, která označuje, zda je toto rozhraní nakonfigurováno pro automatickou registraci informací o IP adrese v systému DNS (Domain Name System).

MulticastAddresses

Získá adresy vícesměrového vysílání přiřazené k tomuto rozhraní.

UnicastAddresses

Získá adresy jednosměrového vysílání přiřazené k tomuto rozhraní.

WinsServersAddresses

Získá adresy serveru WINS (Windows Internet Name Service).

Metody

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí hashovací funkce.

(Zděděno od Object)
GetIPv4Properties()

Poskytuje konfigurační data protokolu IPv4 (Internet Protocol verze 4) pro toto síťové rozhraní.

GetIPv6Properties()

Poskytuje konfigurační data protokolu IPv6 (Internet Protocol verze 6) pro toto síťové rozhraní.

GetType()

Type Získá z aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro