You will need to typecast the QueryResult
collection item to a specific TResultRecord
descendant depending on the RecType
property value of the item. From the Items
property reference:
Use casting to return an object reference that allows access to any properties or method specific to the descendant class associated with the value in TResultRecord.RecType.
The name pattern of the TResultRecord
descendant classes is like this:
T<DNS lookup type>Record
So in your case it would look like this:
for X := 0 to DNS.QueryResult.Count - 1 do
begin
if DNS.QueryResult[X].RecType = qtA then
Result := TARecord(DNS.QueryResult[X]).IPAddress; // "A" lookup -> TARecord
end;
For a AAAA
lookup type it would be:
for X := 0 to DNS.QueryResult.Count - 1 do
begin
if DNS.QueryResult[X].RecType = qtAAAA then
Result := TAAAARecord(DNS.QueryResult[X]).Address; // "AAAA" lookup -> TAAAARecord
end;
Example functions for IPv4 and IPv6 DNS lookups you may find here
.