CDnsClient::GetRecord
INT GetRecord(
LPCTSTR lpszHostName,  
INT nRecordType,  
LPTSTR lpszBuffer,  
INT cbBuffer  
);
INT GetRecord(
LPCTSTR lpszHostName,  
INT nRecordType,  
CString& strBuffer  
);

The GetRecord method returns the specified record information for the given hostname.

Parameters

lpszHostName
Pointer to the string which specifies the host name that information is to be returned about.
nRecordType
The record type for the information that should be returned. The following record types are recognized:
Value Constant Description
0 DNS_RECORD_NONE No record type
1 DNS_RECORD_ADDRESS Host address
2 DNS_RECORD_NS Authoritative nameserver
5 DNS_RECORD_CNAME Cannonical name (alias)
6 DNS_RECORD_SOA Start of Authority
11 DNS_RECORD_WKS Well known services
12 DNS_RECORD_PTR Domain name
13 DNS_RECORD_HINFO Host information
14 DNS_RECORD_MINFO Mailbox information
15 DNS_RECORD_MX Mail exchange host
16 DNS_RECORD_TXT Text strings
29 DNS_RECORD_LOC Location information
100 DNS_RECORD_UINFO User information
101 DNS_RECORD_UID User ID
102 DNS_RECORD_GID Group ID
lpszBuffer
Pointer to the buffer which will contain the host information returned by the nameserver.
cbBuffer
Maximum number of bytes that may be copied into the specified buffer, including the null-byte terminator.

Return Value

If the method succeeds, the length of the information buffer is returned. A return value of zero indicates that no information for that record is available for the specified host. If the method fails, the return value is DNS_ERROR. To get extended error information, call GetLastError.

Remarks

The GetRecord method can be used to resolve a host name into an IP address using the record type DNS_RECORD_ADDRESS. It can also be used to perform a reverse lookup and resolve an IP address into a host name by using the record type DNS_RECORD_PTR.

To determine the host that serves as the primary or master DNS for a zone, the record name should be specified as the domain name (e.g.: microsoft.com) and the record type should be DNS_RECORD_SOA. The value returned will the fully qualified domain name for host.

Note that this method does not reference a local host file when resolving host names or addresses. If the record lookup fails, this method will return an error even if there's an entry for the host in the file that has been specified by a call to SetHostFile.

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

GetHostAddress, GetHostName, GetHostInfo, GetHostServices, GetMailExchange, GetResolverAddress, RegisterServer


Copyright © 2008 Catalyst Development Corporation. All rights reserved.