Query Method  
 

Perform a general nameserver query for a specific type of record.

Syntax

object.Query( RecordName, RecordType, RecordData, [Reserved] )

Parameters

RecordName
A string value that specifies the name of the record that is to be retrieved. Typically this is the name of a given host for which you wish to obtain information.
RecordType
An integer value that specifies the type of record that is to be retrieved. This parameter should be set to one of the following values:
Value Constant Description
0 dnsRecordNone No record type
1 dnsRecordAddress Host address
2 dnsRecordNS Authoritative nameserver
5 dnsRecordCName Canonical name (alias)
6 dnsRecordSOA Start of Authority
11 dnsRecordWKS Well known services
12 dnsRecordPTR Domain name
13 dnsRecordHInfo Host information
14 dnsRecordMInfo Mailbox information
15 dnsRecordMX Mail exchange host
16 dnsRecordTXT Text strings
29 dnsRecordLoc Location information
100 dnsRecordUInfo User information
101 dnsRecordUid User ID
102 dnsRecordGid Group ID
RecordData
A string variable that is set to the data returned as a result of the query. If no data was returned, this argument will be set to an empty string. This parameter must be passed by reference.
Reserved
An optional parameter that is reserved for future use. This parameter should be omitted or passed as an empty variant.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The Query method performs a general nameserver query for a given record based on the name and type. This method will not use a local host file when performing host name or IP address lookups.

The dnsRecordAddress record type is used to resolve a host name into an IP address, and is the most common type of nameserver query that is performed. This is the type of query that is used when you set the HostName property and then read the HostAddress property to obtain it's IP address. If the host name has both an IPv4 and IPv6 address, this method will return the IPv4 address by default for compatibility with existing applications. It will only return an IPv6 address if the host has no IPv4 address assigned to it.

The dnsRecordPTR record type is used to resolve an IP address into a host name, and is also referred to as a reverse DNS lookup. The RecordName argument should be set to the IP address of the system, and the RecordData argument will contain its fully qualified domain name when the method returns. Note that this requires that a PTR record actually exists for the given address, which may not be the case. This is the same type of query that is performed when you set the HostAddress property and then read the HostName property to determine the host name.

See Also

HostAddress Property, HostName Property, MailExchange Property, Resolve Method