TPing.DNSResult

From Overbyte
Jump to navigation Jump to search

Main page -> ICS component reference -> TPing -> DNSResult

Definition

property DNSResult: string;

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. The DNSResult property will contain the IPv4 or IPv6 address of the remote host specified in address property. Be aware that this information is being queried in the background and thus is not available immediately. It is available when the OnDNSLookupDone event fired.

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
   ShowMessage(Ping1.DnsResult);
 end;
 
 end.
 

</syntaxhighlight>

Best practices

Process the contents of this property in OnDNSLookupDone event if the Error parameter of this event is 0.

How to