IPInterfaceProperties Klasa

Definicja

Zawiera informacje o interfejsach sieciowych obsługujących protokół internetowy w wersji 4 (IPv4) lub protokołu internetowego w wersji 6 (IPv6).

public ref class IPInterfaceProperties abstract
public abstract class IPInterfaceProperties
type IPInterfaceProperties = class
Public MustInherit Class IPInterfaceProperties
Dziedziczenie
IPInterfaceProperties

Przykłady

Poniższy przykładowy kod wyświetla informacje o adresie.

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

Uwagi

Ta klasa zapewnia dostęp do informacji o konfiguracji i adresach dla interfejsów sieciowych obsługujących protokół IPv4 lub IPv6. Nie należy tworzyć wystąpień tej klasy; są zwracane przez metodę GetIPProperties .

Aby uzyskać dostęp do właściwości specyficznych dla protokołu IPv4, użyj obiektu zwróconego przez metodę GetIPv4Properties . Aby uzyskać dostęp do właściwości specyficznych dla protokołu IPv6, użyj obiektu zwróconego przez metodę GetIPv6Properties .

Konstruktory

IPInterfaceProperties()

Inicjuje nowe wystąpienie klasy IPInterfaceProperties.

Właściwości

AnycastAddresses

Pobiera wszystkie adresy IP emisji przypisane do tego interfejsu.

DhcpServerAddresses

Pobiera adresy serwerów protokołu DHCP (Dynamic Host Configuration Protocol) dla tego interfejsu.

DnsAddresses

Pobiera adresy serwerów systemu nazw domen (DNS) dla tego interfejsu.

DnsSuffix

Pobiera sufiks systemu nazw domen (DNS) skojarzony z tym interfejsem.

GatewayAddresses

Pobiera adresy bramy sieci IPv4 dla tego interfejsu.

IsDnsEnabled

Pobiera wartość wskazującą Boolean , czy usługa NetBt jest skonfigurowana do używania rozpoznawania nazw DNS w tym interfejsie.

IsDynamicDnsEnabled

Pobiera wartość wskazującą Boolean , czy ten interfejs jest skonfigurowany do automatycznego rejestrowania informacji o adresie IP za pomocą systemu nazw domen (DNS).

MulticastAddresses

Pobiera adresy multiemisji przypisane do tego interfejsu.

UnicastAddresses

Pobiera adresy emisji pojedynczej przypisane do tego interfejsu.

WinsServersAddresses

Pobiera adresy serwerów usługi nazw internetowych systemu Windows (WINS).

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetIPv4Properties()

Udostępnia dane konfiguracji protokołu internetowego w wersji 4 (IPv4) dla tego interfejsu sieciowego.

GetIPv6Properties()

Udostępnia dane konfiguracji protokołu internetowego w wersji 6 (IPv6) dla tego interfejsu sieciowego.

GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy