GetComputerNameEx

 

Description

 

Retrieves a NetBIOS or DNS name associated with the local computer. The names are established at system startup, when the system reads them from the registry.

 

C++ Syntax

 

BOOL WINAPI GetComputerNameEx(

__in    COMPUTER_NAME_FORMAT NameType,

__out   LPTSTR lpBuffer,

__inout LPDWORD lpnSize

);

 

PowerBASIC Syntax

 

FUNCTION GetComputerNameEx ( _

BYVAL NameType AS LONG, _

BYREF lpBuffer AS ASCIIZ, _

BYREF lpnSize AS DWORD _

) AS LONG

 

Unicode version

 

FUNCTION GetComputerNameExW ( _

BYVAL NameType AS LONG, _

BYVAL lpBuffer AS DWORD, _

BYREF lpnSize AS DWORD _

) AS LONG

 

Parameters

 

NameType

 

[in] The type of name to be retrieved. This parameter is a value from the COMPUTER_NAME_FORMAT enumeration type. The following table provides additional information.

 

Value

Meaning

ComputerNameDnsDomain

The name of the DNS domain assigned to the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS domain name of the cluster virtual server.

ComputerNameDnsFullyQualified

The fully qualified DNS name that uniquely identifies the local computer. This name is a combination of the DNS host name and the DNS domain name, using the form HostName.DomainName. If the local computer is a node in a cluster, lpBuffer receives the fully qualified DNS name of the cluster virtual server.

ComputerNameDnsHostname

The DNS host name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS host name of the cluster virtual server.

ComputerNameNetBIOS

The NetBIOS name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the NetBIOS name of the cluster virtual server.

ComputerNamePhysicalDnsDomain

The name of the DNS domain assigned to the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS domain name of the local computer, not the name of the cluster virtual server.

ComputerNamePhysicalDnsFullyQualified

The fully qualified DNS name that uniquely identifies the computer. If the local computer is a node in a cluster, lpBuffer receives the fully qualified DNS name of the local computer, not the name of the cluster virtual server.

 

The fully qualified DNS name is a combination of the DNS host name and the DNS domain name, using the form HostName.DomainName.

ComputerNamePhysicalDnsHostname

The DNS host name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the DNS host name of the local computer, not the name of the cluster virtual server.

ComputerNamePhysicalNetBIOS

The NetBIOS name of the local computer. If the local computer is a node in a cluster, lpBuffer receives the NetBIOS name of the local computer, not the name of the cluster virtual server.

 

lpBuffer

 

[out] A pointer to a buffer that receives the computer name or the cluster virtual server name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1 characters.

 

lpnSize

 

[in, out] On input, specifies the size of the buffer, in TCHARs. On output, receives the number of TCHARs copied to the destination buffer, not including the terminating null character.

 

If the buffer is too small, the function fails and GetLastError returns ERROR_MORE_DATA. This parameter receives the size of the buffer required, including the terminating null character.

 

If lpBuffer is NULL, this parameter must be zero.

 

Return Value

 

If the function succeeds, the return value is a nonzero value.

 

If the function fails, the return value is zero. To get extended error information, call GetLastError. Possible values include the following.

 

Return Code

Description

ERROR_MORE_DATA

The lpBuffer buffer is too small. The lpnSize parameter contains the number of bytes required to receive the name.

 

Remarks

 

If group policy is not set for the local machine, the GetComputerNameEx function retrieves the NetBIOS or DNS names established at system startup. If group policy is set, the function returns the primary domain name set by group policy. Name changes made by the SetComputerName or SetComputerNameEx functions do not take effect until the user restarts the computer.

 

If the local computer is not configured to use DNS names, GetComputerNameEx will not return DNS information. To configure the computer to do this, follow the steps outlined in the operating system help and change the primary DNS suffix of the computer, then restart the computer.

 

The behavior of this function can be affected if the local computer is a node in a cluster. For more information, see ResUtilGetEnvironmentWithNetName and UseNetworkName.

 

If you are working with environments that use different DNS layouts, where the computer's FQDN does not match the FQDN of its domain, use LsaQueryInformationPolicy instead.

 

Valid XHTML 1.0 Transitional