Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DnsHostnameToComputerName function

Converts a DNS-style host name to a NetBIOS-style computer name.

Syntax


BOOL WINAPI DnsHostnameToComputerName(
  _In_     LPCTSTR Hostname,
  _Out_    LPTSTR ComputerName,
  _Inout_  LPDWORD nSize
);

Parameters

Hostname [in]

The DNS name. If the DNS name is not a valid, translatable name, the function fails. For more information, see Computer Names.

ComputerName [out]

A pointer to a buffer that receives the computer name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1 characters.

nSize [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, GetLastError returns ERROR_MORE_DATA, and nSize receives the required buffer size, not including the terminating null character.

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 codeDescription
ERROR_MORE_DATA

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

 

Remarks

This function performs a textual mapping of the name. This convention limits the names of computers to be the common subset of the names. (Specifically, the leftmost label of the DNS name is truncated to 15-bytes of OEM characters.) Therefore, do not use this function to convert a DNS domain name to a NetBIOS domain name. There is no textual mapping for domain names.

To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

DnsHostnameToComputerNameW (Unicode) and DnsHostnameToComputerNameA (ANSI)

See also

GetComputerNameEx
SetComputerNameEx
System Information Functions

 

 

Community Additions

Show:
© 2014 Microsoft