CDnsClient::GetHostName Method  
 
INT GetHostName(
  LPCTSTR lpszHostAddress,  
  LPTSTR lpszHostName,  
  INT nMaxLength  
);
INT GetHostName(
  LPCTSTR lpszHostAddress,  
  CString& strHostName  
);

The GetHostName method resolves the specified IP address, storing the fully qualified host name in the provided buffer.

Parameters

lpszHostAddress
Pointer to a string that specifies an IPv4 or IPv6 formatted address.
lpszHostName
Pointer to the buffer that will contain the fully qualified domain name for the specified host. This buffer should be at least 64 characters in length.
nMaxLength
The maximum length of the string buffer.

Return Value

If the method succeeds, the return value is the number of characters copied into the host name buffer. If the method fails, the return value is DNS_ERROR. To get extended error information, call GetLastError.

Remarks

The GetHostName method first looks to see if there is an entry in the local host file for the specified IP address, and if one exists, it will return the host name for that address. If you do not want to use the local host file at all, and only return an host name if a DNS query resolves the address, use the GetRecord method and specify a record type of DNS_RECORD_PTR.

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csdnsv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

EnumHostAliases, GetHostByAddress, GetHostByName, GetHostAddress