Delphi / Indy resolve DNS domain by host name lookup
<p>I'm trying to use a hardcoded AName, some code using JNI on Delphi 10.1 update 2, and TIdDNSResolver to do the following:</p>

<p>1) Get the device DNS server(s) from the device interface config (works!)</p>

<p>2) Do a lookup on the DNS server to retrieve that server's domain name (fails!)</p>

<p>3) Append the DNS Domain to the hardcoded AName (not there yet)</p>

<p>4) Use the FQDN AName to lookup the server IP Address (not there yet)</p>

<p>So far using JNI functions in Delphi I can get the DNS server(s) IP Address. When I  try to lookup the domain name I'm failing. Here's my code:</p>

<pre><code>dns.Host := s;
dns.WaitingTime := 2048;
dns.QueryType := [qtDName];
dns.Resolve('hard_coded_server_name');
for i := 0 to Pred(dns.QueryResult.Count) do
begin
  r := dns.QueryResult[i];
  case r.RecType of
    qtDName:  begin
                txt := TTextRecord(r);
                Memo1.Lines.AddStrings(txt.Text);
              end;
  end;
end;
</code></pre>

<p>I'm certain that I'm using the TResultRecord incorrectly, but couldn't find docs on how to do this correctly. Could someone (Remy?) please explain how to do this?</p>

<p>Thanks.</p>