|
|
| BOOL Resolve(
|
|
|
LPCTSTR
lpszRecord, |
|
|
|
|
LPTSTR
lpszResult, |
|
|
|
|
INT nMaxLength, |
|
|
|
|
BOOL bHostName |
|
|
| );
|
| BOOL Resolve(
|
|
|
LPCTSTR
lpszRecord, |
|
|
|
|
LPDWORD
lpdwAddress |
|
|
| );
|
| BOOL Resolve(
|
|
|
DWORD
dwAddress, |
|
|
|
|
LPTSTR
lpszHostName, |
|
|
|
|
INT nMaxLength |
|
|
| );
|
| BOOL Resolve(
|
|
|
LPCTSTR
lpszRecord, |
|
|
|
|
CString&
strResult, |
|
|
|
|
BOOL bHostName |
|
|
| );
|
| BOOL Resolve(
|
|
|
DWORD
dwAddress, |
|
|
|
|
CString&
strHostName |
|
|
| );
|
The Resolve method resolves the specified host name into
an IP address, or an IP address into its corresponding host
name.
Parameters
- lpszRecord
- Pointer to a null-terminated string which specifies the record
to be resolved. If the bHostName argument is non-zero, then
the record is expected to be a host name; otherwise it is expected
to be an IP address string in dot notation.
- lpszResult
- Pointer to the buffer that will contain the result of the
nameserver query. If the bHostName argument is non-zero,
then the string will contain the host's IP address in dot notation
when the method returns; otherwise, it will contain the host name
for the IP address specified in the lpszRecord
argument.
- nMaxLength
- The maximum number of characters that can be copied into the
string buffer.
- bHostName
- A boolean argument which determines how the record is resolved.
If this value is non-zero, then the lpszRecord argument
should specify a host name and the lpszResult buffer will
contain the IP address for that host when the method returns. If
this value is zero, then the lpszRecord argument should
specify an IP address and the lpszResult buffer will contain
its host name when the method returns.
- dwAddress
- An unsigned long integer which specifies the numeric form of an
IP address in network byte order. This can be used with versions of
the method that resolve host names and addresses using the numeric
form of the IP address instead of a string.
Return Value
If the method succeeds, the return value is non-zero. If the
method fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
The Resolve method provides a convenient interface to
resolve host names and IP addresses. Note that this method first
looks to see if there is an entry in the local host file for the
specified host name or IP address, and if one exists, it will
return that record without querying the name server.
Example
// Create an instance of the class object
CDnsClient dnsClient;
// Resolve the address of the www.microsoft.com server
CString strHostName = _T("www.microsoft.com");
DWORD dwHostAddress;
// If the host name is resolved, then perform a reverse
// lookup on that address to obtain the actual host name
// for that server
if (dnsClient.Resolve(strHostName, &dwHostAddress))
dnsClient.Resolve(dwHostAddress, strHostName);
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
GetAddress, FormatAddress, GetHostAddress, GetHostFile, GetHostName, SetHostFile
|
|