Export (0) Print
Expand All

IPGlobalProperties.HostName Property

Gets the host name for the local computer.

Namespace:  System.Net.NetworkInformation
Assembly:  System (in System.dll)

public abstract string HostName { get; }

Property Value

Type: System.String
A String instance that contains the computer's NetBIOS name.

ExceptionCondition
NetworkInformationException

A Win32 function call failed.

A computer's NetBIOS name must be unique within a network and is not fully qualified by the domain name.

The following code example displays network information for the local computer.

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(S"Computer name: {0}", properties->HostName);
Console::WriteLine(S"Domain name:   {0}", properties->DomainName);
Console::WriteLine(S"Node type:     {0:f}", __box(properties->NodeType));
Console::WriteLine(S"DHCP scope:    {0}", properties->DhcpScopeName);
Console::WriteLine(S"WINS proxy?    {0}", __box(properties->IsWinsProxy));

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft