unit uPing;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdRawBase, IdRawClient,
IdIcmpClient;
type
TForm1 =
class(TForm)
Button1: TButton;
Edit1: TEdit;
Ping: TIdIcmpClient;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure PingReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PingReply(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
ListBox1.Clear;
Ping.ReceiveTimeout := 1000;
Ping.Host := Edit1.Text;
for i := 1
to 10
do
begin
Ping.Ping;
Application.ProcessMessages;
end;
end;
end.