Registriert seit: 10. Jun 2002
Ort: Unterhaching
11.412 Beiträge
Delphi 12 Athens
|
Re: DNS Server nach IP befragen ?
24. Feb 2004, 18:04
Okay, hier die Lösung:
Delphi-Quellcode:
uses
IdDNSResolver;
{...}
function TForm1.GetWWWServerIp(DNSServer, Address: AnsiString): String;
var
I, P: Integer;
idDnsResolver: TIdDNSResolver;
A: TARecord;
function PadZero(Val: Integer): AnsiString;
begin
Result := IntToStr(Val);
while Length(Result) < 5 do
Result := '0' + Result;
end;
begin
Result := '';
idDnsResolver := TIdDNSResolver.Create(nil);
try
// resolve host domain server
idDnsResolver.QueryResult.Clear;
idDnsResolver.QueryRecords := [qtA];
idDnsResolver.Host := DNSServer;
idDnsResolver.ReceiveTimeout := 5000;
try
idDnsResolver.Resolve(Address);
except
idDnsResolver.QueryResult.Clear;
end;
if idDnsResolver.QueryResult.Count > 0 then
for I := 0 to Pred(idDnsResolver.QueryResult.Count) do
if idDnsResolver.QueryResult.Items[I] is TARecord then
begin
A := (idDnsResolver.QueryResult.Items[I] as TARecord);
Result := Result + A.IPAddress + ',';
end;
finally
idDnsResolver.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// BITTE EINEN KORREKTEN DNS SERVER ANGEBEN!!!
ShowMessage(GetWWWServerIp('192.168.64.3', Edit1.Text));
end;
... ...
Daniel Lizbeth Ich bin nicht zurück, ich tue nur so
|
|
Zitat
|