| |
| BOOL Resolve(
|
| |
LPCTSTR lpszRecord, |
|
| |
LPTSTR lpszResult, |
|
| |
INT nMaxLength, |
|
| |
BOOL bHostName |
|
| );
|
| BOOL Resolve(
|
| |
LPCTSTR lpszRecord, |
|
| |
LPINTERNET_ADDRESS lpAddress |
|
| );
|
| BOOL Resolve(
|
| |
LPINTERNET_ADDRESS lpAddress, |
|
| |
LPTSTR lpszHostName, |
|
| |
INT nMaxLength |
|
| );
|
| BOOL Resolve(
|
| |
LPCTSTR lpszRecord, |
|
| |
CString& strResult, |
|
| |
BOOL bHostName |
|
| );
|
| BOOL Resolve(
|
| |
LPINTERNET_ADDRESS lpAddress, |
|
| |
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.
- lpAddress
- A pointer to an INTERNET_ADDRESS structure which specifies the
numeric form of an IPv4 or IPv6 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");
INTERNET_ADDRESS ipHostAddress;
// 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, &ipHostAddress))
dnsClient.Resolve(&ipHostAddress, strHostName);
Requirements
Client: Requires Windows 7, Windows Vista or Windows
XP.
Server: Requires Windows Server 2008 or Windows Server
2003.
Header: Include cstools7.h.
Library: Use csdnsav7.lib.
Unicode: Implemented as Unicode and ANSI versions.
See Also
GetAddress, FormatAddress, GetHostAddress, GetHostFile, GetHostName, SetHostFile, INTERNET_ADDRESS
|
|