TPing.OnDNSLookupDone
Main page -> ICS component reference -> TPing -> OnDNSLoopupDone
Definition
event OnDNSLookupDoneSender:TObject; Error: Word;
Description
If the address property is specified as DNS address instead of an IP address, a DNS lookup will be performed by the ping component. Be aware that this information is being queried in the background. After this DNS lookup completed, this OnDNSLookupDone event will be fired.
The DNSResult property will contain the IPv4 or IPv6 address of the remote host specified in address property.
Example
<syntaxhighlight lang="delphi">
unit MainForm; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, OverbyteIcsWndControl, OverbyteIcsPing, Vcl.StdCtrls; type TForm1 = class(TForm) Ping1: TPing; Button1: TButton; procedure Ping1DnsLookupDone(Sender: TObject; Error: Word); procedure Button1Click(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin Ping1.DnsLookup('wikipedia.org'); end; procedure TForm1.Ping1DnsLookupDone(Sender: TObject; Error: Word); begin if Error = 0 then ShowMessage(Ping1.DnsResult); else ShowMessage('Error on DNS lookup. Code: ' + IntToStr(Error)); end; end.
</syntaxhighlight>
Best practices
Process the contents of the DNSResult property in OnDNSLookupDone event if the Error parameter of this event is 0.