CDnsClient::GetHostName
INT GetHostName(
LPCTSTR lpszHostAddress,  
LPTSTR lpszHostName,  
INT cchHostName  
);
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 the string that contains the IP address to be resolved. The address must be in common dot notation, with each byte of the address separated by a period.
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.
cchHostName
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

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use csdnsav6.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

EnumHostAliases, GetHostByAddress, GetHostByName, GetHostAddress


Copyright © 2008 Catalyst Development Corporation. All rights reserved.