how to lookup dns records with indy in delphi
<p>How can I lookup DNS records with Indy in Delphi?  For example, <code>SRV</code> records, <code>SPF</code> records, <code>TEXT</code> records, etc.</p>

<p>I know we can use <code>nslookup</code> directly from Windows, but I want to do this with Indy, or any other Delphi component.</p>

<p>I tried searching Google, and I found something like this:</p>

<pre><code>function ReverseDNSLookup(IPAddress: String; DNSServer: String =
SDefaultDNS; Timeout: Integer = 30; Retries: Integer = 3) : string;
var
  AIdDNSResolver: TIdDNSResolver;
  RetryCount: Integer;
begin
  Result := '';
  IPAddress := ReverseIP(IPAddress);

  AIdDNSResolver := TIdDNSResolver.Create(nil);
  try
    AIdDNSResolver.QueryResult.Clear;
    AIdDNSResolver.WaitingTime := Timeout;
    AIdDNSResolver.QueryType := [qtPTR];
    AIdDNSResolver.Host := DNSServer;

    RetryCount := Retries;
    repeat
      try
        dec(RetryCount);

        AIdDNSResolver.Resolve(IPAddress);

        Break;
      except
        on e: Exception do
        begin
          if RetryCount &lt;= 0 then
          begin
    //            if SameText(e.Message, RSCodeQueryName) then
    //              Result := FALSE
    //            else
                  raise Exception.Create(e.Message);
            Break;
          end;
        end;
      end;
    until false;

    if AIdDNSResolver.QueryResult.Count &gt; 0 then
      Result := AIdDNSResolver.QueryResult.DomainName;
  finally
    FreeAndNil(AIdDNSResolver);
  end;
end;
</code></pre>

<p>But all it is for is looking up IP addresses.  I want <code>SRV</code> and <code>TEXT</code> records, and maybe <code>SPF</code> records.</p>