IPInterfaceProperties 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供支援網際網路協定版本4(IPv4)或網際網路協定版本6(IPv6)的網路介面資訊。
public ref class IPInterfaceProperties abstract
public abstract class IPInterfaceProperties
type IPInterfaceProperties = class
Public MustInherit Class IPInterfaceProperties
- 繼承
-
IPInterfaceProperties
範例
以下程式碼範例顯示地址資訊。
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 物件。
建構函式
| 名稱 | Description |
|---|---|
| IPInterfaceProperties() |
初始化 IPInterfaceProperties 類別的新執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| AnycastAddresses |
取得分配給此介面的任播 IP 位址。 |
| DhcpServerAddresses |
取得此介面的動態主機配置協定(DHCP)伺服器位址。 |
| DnsAddresses |
取得此介面的網域名稱系統(DNS)伺服器位址。 |
| DnsSuffix |
此介面會獲得與此介面相關的網域名稱系統(DNS)後綴。 |
| GatewayAddresses |
取得此介面的 IPv4 網路閘道位址。 |
| IsDnsEnabled |
會得到 Boolean 一個值,指示 NetBt 是否設定在此介面使用 DNS 名稱解析。 |
| IsDynamicDnsEnabled |
會獲得 Boolean 一個值,指示此介面是否設定為自動向網域名稱系統(DNS)註冊其 IP 位址資訊。 |
| MulticastAddresses |
取得分配給此介面的多播位址。 |
| UnicastAddresses |
取得分配給此介面的單播地址。 |
| WinsServersAddresses |
取得 Windows 網際網路名稱服務(WINS)伺服器的位址。 |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetIPv4Properties() |
提供此網路介面的網際網路協定第4版(IPv4)配置資料。 |
| GetIPv6Properties() |
提供此網路介面的網際網路協定第6版(IPv6)配置資料。 |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |