Урок на Делфи 58. Пинг (ping).


задание на delphi. Ping с помощью IcmpClient.

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls,
IdBaseComponent, IdComponent, IdRawBase, IdRawClient, IdIcmpClient;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Edit1: TEdit;
Timer1: TTimer;
IdIcmpClient1: TIdIcmpClient;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if Button1.Tag=0 then
begin
Timer1.Enabled:=true;
Button1.Tag:=1;
end
else
begin
Timer1.Enabled:=false;
Button1.Tag:=0;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
IdIcmpClient1.Host:=Edit1.Text;
IdIcmpClient1.Ping;
Memo1.Lines.Add(IntToStr(IdIcmpClient1.ReplyStatus.MsRoundTripTime)+' ms');
end;
end.



Скачать