| INT
GetHostFile(
|
|
|
LPTSTR
lpszFileName, |
|
|
|
|
INT
cchMaxLength |
|
|
| );
|
| INT
GetHostFile(
|
|
|
CString&
strFileName |
|
|
| );
|
The GetHostFile method returns the name of the host file
previously set using the SetHostFile method. The host file
is used as a database that maps an IP address to one or more
hostnames, and is used by the GetHostAddress and
GetHostName method.
Parameters
- lpszFileName
- Pointer to a null-terminated 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 method will return the length of the string, not including
the terminating null byte.
- cchMaxLength
- The maximum number of characters that may be copied to the
string buffer.
Return Value
If the method succeeds, the return value is length of the
string. A return value of zero indicates that no host file has been
specified or the method was unable to determine the file name. To
get extended error information, call GetLastError. If the
last error is zero, this indicates that no host file name has been
specified for the current thread. If the last error is non-zero,
this indicates the reason that the method failed.
Remarks
This method only returns the name of the host file that is
cached in memory for the current thread. 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
SetHostFile method.
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 method may be different than the
default host file for the local system. To determine the file name
for the default host file, use the GetDefaultHostFile
method.
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
GetDefaultHostFile,
GetHostAddress, GetHostName, SetHostFile
|