unit U_IdIcmpPing;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdRawBase, IdRawClient,
IdIcmpClient, ExtCtrls;
type
TForm1 = class(TForm)
IdIcmpClient1: TIdIcmpClient;
Panel1: TPanel;
edtIP: TEdit;
btnPing: TButton;
Memo: TMemo;
procedure btnPingClick(Sender: TObject);
procedure IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnPingClick(Sender: TObject);
begin
with IdIcmpClient1 do
begin
ReceiveTimeout:=100;
Host:=edtIP.Text;
Ping;
end;
end;
procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
begin
if AReplyStatus.FromIpAddress<>'0.0.0.0' then
Memo.Lines.Add('Ping '+edtip.Text+' Successful!')
else
Memo.Lines.Add('Ping '+edtip.Text+' Failure!')
end;
end.