共用方式為


IPGlobalProperties.HostName 屬性

定義

取得本機電腦的主機名稱。

public:
 abstract property System::String ^ HostName { System::String ^ get(); };
public abstract string HostName { get; }
member this.HostName : string
Public MustOverride ReadOnly Property HostName As String

屬性值

String 執行個體,包含電腦的 NetBIOS 名稱。

例外狀況

Win32 函式呼叫失敗。

範例

下列程式代碼範例會顯示本機計算機的網路資訊。

IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties();
Console::WriteLine( "Computer name: {0}", properties->HostName );
Console::WriteLine( "Domain name:   {0}", properties->DomainName );
Console::WriteLine( "Node type:     {0:f}", properties->NodeType );
Console::WriteLine( "DHCP scope:    {0}", properties->DhcpScopeName );
Console::WriteLine( "WINS proxy?    {0}", properties->IsWinsProxy );
IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
Console.WriteLine("Computer name: {0}", properties.HostName);
Console.WriteLine("Domain name:   {0}", properties.DomainName);
Console.WriteLine("Node type:     {0:f}", properties.NodeType);
Console.WriteLine("DHCP scope:    {0}", properties.DhcpScopeName);
Console.WriteLine("WINS proxy?    {0}", properties.IsWinsProxy);

備註

此屬性會呼叫原生IP協助程式函式 GetNetworkParams,其會傳回包含NetBIOS主機名字符串的FIXED_INFO結構。 當主機名字符串超過 15 個字元時,就會被截斷。

計算機的 NetBIOS 名稱在網路內必須是唯一的,而且未由功能變數名稱完整限定。

適用於