IPInterfaceProperties Class
Provides information about network interfaces that support Internet Protocol version 4 (IPv4) or Internet Protocol version 6 (IPv6).
Assembly: System (in System.dll)
This class provides access to configuration and address information for network interfaces that support IPv4 or IPv6. You do not create instances of this class; they are returned by the GetIPProperties method.
To access IPv4-specific properties, use the object returned by the GetIPv4Properties method. To access IPv6-specific properties, use the object returned by the GetIPv6Properties method.
The following code example displays address information.
void ShowIPAddresses(IPInterfaceProperties* adapterProperties)
{
IPAddressInformationCollection* dnsServers = adapterProperties->DnsAddresses;
if (dnsServers != 0)
{
System::Collections::IEnumerator* myEnum = dnsServers->GetEnumerator();
while (myEnum->MoveNext())
{
IPAddressInformation* dns = __try_cast<IPAddressInformation*>(myEnum->Current);
Console::WriteLine(S" DNS Servers ............................. : {0} ({1} {2})",
dns->Address,
dns->IsTransient ? S"Transient" : S"",
dns->IsDnsEligible ? S"DNS Eligible" : S""
);
}
}
IPAddressInformationCollection* anyCast = adapterProperties->AnycastAddresses;
if (anyCast != 0)
{
System::Collections::IEnumerator* myEnum1 = anyCast->GetEnumerator();
while (myEnum1->MoveNext())
{
IPAddressInformation* any = __try_cast<IPAddressInformation*>(myEnum1->Current);
Console::WriteLine(S" Anycast Address .......................... : {0} {1} {2}",
any->Address,
any->IsTransient ? S"Transient" : S"",
any->IsDnsEligible ? S"DNS Eligible" : S""
);
}
Console::WriteLine();
}
IPAddressInformationCollection* multiCast = adapterProperties->MulticastAddresses;
if (multiCast != 0)
{
System::Collections::IEnumerator* myEnum2 = multiCast->GetEnumerator();
while (myEnum2->MoveNext())
{
IPAddressInformation* multi = __try_cast<IPAddressInformation*>(myEnum2->Current);
Console::WriteLine(S" Multicast Address ....................... : {0} {1} {2}",
multi->Address,
multi->IsTransient ? S"Transient" : S"",
multi->IsDnsEligible ? S"DNS Eligible" : S""
);
}
Console::WriteLine();
}
IPUnicastAddressInformationCollection* uniCast = adapterProperties->UnicastAddresses;
if (uniCast != 0)
{
String* lifeTimeFormat = S"dddd, MMMM dd, yyyy hh:mm:ss tt";
System::Collections::IEnumerator* myEnum3 = uniCast->GetEnumerator();
while (myEnum3->MoveNext())
{
IPUnicastAddressInformation* uni = __try_cast<IPUnicastAddressInformation*>(myEnum3->Current);
DateTime when;
Console::WriteLine(S" Unicast Address ......................... : {0}", uni->Address);
Console::WriteLine(S" Prefix Origin ........................ : {0}", __box(uni->PrefixOrigin));
Console::WriteLine(S" Suffix Origin ........................ : {0}", __box(uni->SuffixOrigin));
Console::WriteLine(S" Duplicate Address Detection .......... : {0}", __box(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(S" Valid Life Time ...................... : {0}",
when.ToString(lifeTimeFormat,System::Globalization::CultureInfo::CurrentCulture)
);
when = DateTime::UtcNow + TimeSpan::FromSeconds((double)uni->AddressPreferredLifetime);
when = when.ToLocalTime();
Console::WriteLine(S" Preferred life time .................. : {0}",
when.ToString(lifeTimeFormat,System::Globalization::CultureInfo::CurrentCulture)
);
when = DateTime::UtcNow + TimeSpan::FromSeconds((double)uni->DhcpLeaseLifetime);
when = when.ToLocalTime();
Console::WriteLine(S" DHCP Leased Life Time ................ : {0}",
when.ToString(lifeTimeFormat,System::Globalization::CultureInfo::CurrentCulture)
);
}
Console::WriteLine();
}
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.