簡単 :
program SO18309621;
{$APPTYPE CONSOLE}
uses
IdDNSResolver,
SysUtils;
var
Dns : TIdDNSResolver;
Rec : TResultRecord;
Srv : TSRVRecord;
Index : Integer;
begin
try
Dns := TIdDNSResolver.Create;
try
Dns.Host := 'mydnsserver.mydomain';
Dns.QueryType := [qtService];
Dns.Resolve('_ldap._tcp.mydomain');
for Index := 0 to Dns.QueryResult.Count - 1 do
begin
Rec := Dns.QueryResult[Index];
if Rec is TSRVRecord then
begin
Srv := TSRVRecord(Rec);
Writeln('Target=', Srv.Target, ', Port=', Srv.Port, ', Priority=', Srv.Priority, ', Weight=', Srv.Weight);
end;
end;
finally
Dns.Free;
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.