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 Description
dnsRecordNone No record type
dnsRecordAddress Host address
dnsRecordNS Authoritative nameserver
dnsRecordCName Canonical name (alias)
dnsRecordSOA Start of Authority
dnsRecordWKS Well known services
dnsRecordPTR Domain name
dnsRecordHInfo Host information
dnsRecordMInfo Mailbox information
dnsRecordMX Mail exchange host
dnsRecordTXT Text strings
dnsRecordLoc Location information
dnsRecordUInfo User information
dnsRecordUid User ID
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