InetGetHostName Function  
 
INT WINAPI InetGetHostName(
  LPINTERNET_ADDRESS lpAddress,  
  LPTSTR lpszHostName,  
  INT cchHostName  
);

The InetGetHostName function performs a reverse lookup, returning the host name associated with a given IP address.

Parameters

lpAddress
A pointer to an INTERNET_ADDRESS structure which specifies the IP address that should be resolved into a host name.
lpszHostName
The buffer that will contain the host name. It is recommended that this buffer be at least 256 characters in length to accommodate the longest possible fully qualified domain name.
cchHostName
The maximum number of characters that can be copied into the buffer.

Return Value

If the function succeeds, the return value is the length of the hostname. If the function fails, the return value is INET_ERROR. To get extended error information, call InetGetLastError.

Remarks

If the function must perform a reverse DNS lookup to resolve the IP address into a host name, the calling thread will block. This function requires that the host have a PTR record, otherwise it will fail. Because many hosts do not have a PTR record, calling this function frequently may have a negative impact on the overall performance of the application.

To determine if the local system has an IPv6 TCP/IP stack installed and configured on the local system, use the InetIsProtocolAvailable function. If an IPv6 stack is not installed, this function will fail if the lpAddress parameter specifies an IPv6 address, even if the address itself is valid.

Requirements

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

See Also