unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdRawBase, IdRawClient,
IdIcmpClient, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
ICMP: TIdIcmpClient;
ListBox1: TListBox;
procedure ICMPReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ICMPReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime:
string;
begin
if (AReplyStatus.MsRoundTripTime = 0)
then
sTime := '
< 1'
else
sTime := '
=';
Listbox1.Items.Add(Format('
%d bytes from %s: icmp_seq=%d ttl=%d time%s%d ms',
[AReplyStatus.BytesReceived,
AReplyStatus.FromIpAddress,
AReplyStatus.SequenceId,
AReplyStatus.TimeToLive,
sTime,
AReplyStatus.MsRoundTripTime]));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
Icmp.Host := '
www.delphi-treff.de';
for i := 1
to 4
do
begin
Icmp.Ping;
Application.ProcessMessages;
end;
end;
end.