INT WINAPI DnsGetHostFile( |
|
HCLIENT hClient, |
|
|
LPTSTR lpszFileName, |
|
|
INT nMaxLength |
|
); |
The DnsGetHostFile function returns the name of the host
file previously set using the DnsSetHostFile function. The
host file is used as a database that maps an IP address to one or
more hostnames, and is used by the DnsGetHostAddress and
DnsGetHostName function.
Parameters
- hClient
- Handle to the client session.
- lpszFileName
- Pointer to a string buffer that will contain
the host file name. It is recommended that this buffer be at least
MAX_PATH characters in size. This parameter may be NULL, in which
case the function will return the length of the string, not
including the terminating null character.
- nMaxLength
- The maximum number of characters that may be copied to the
string buffer.
Return Value
If the function succeeds, the return value is the number of
characters copied into the string buffer, not including the
terminating null character. A return value of zero indicates
no host file has been specified or the function was unable to
determine the file name. To get extended error information,
call DnsGetLastError.
Remarks
This function returns the name of the host file that is
cached in memory for the current thread. If an alternate host file has
not been specified, this function will return the path to the default
host file. The contents of the file on
the disk may have changed after the file was loaded into memory. To
reload the host file or clear the cache, call the
DnsSetHostFile function.
If a host file has been specified, it is processed before the
default host file when resolving a hostname into an IP address, or an
IP address into a hostname. If the host name or address is not found,
or no host file has been specified, a nameserver lookup is
performed.
The host file returned by this function may be different than the
default host file for the local system. To determine the file name
for the default host file, use the DnsGetDefaultHostFile
function.
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: csdnsv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
DnsGetDefaultHostFile,
DnsGetHostAddress,
DnsGetHostName,
DnsSetHostFile
|