?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IdBaseComponent, IdComponent, IdRawBase,
IdRawClient, IdIcmpClient, SkinCaption, WinSkinData;
type
TForm1 = class(TForm)
Edit1: TEdit;
Panel1: TPanel;
Button1: TButton;
Label1: TLabel;
Button2: TButton;
ICMP: TIdIcmpClient;
ListBox1: TListBox;
SkinData1: TSkinData;
SkinCaption1: TSkinCaption;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ICMPReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
ICMP.Host := Edit1.Text ; //宿主計算機的名稱或IP地址
ICMP.ReceiveTimeout := 1000; //最大等待時間
Button1.Enabled := false;
try
for i:=0 to 3 do //重復4次
begin
ICMP.Ping ;
Application.ProcessMessages ; //延時
end;
finally
Button1.Enabled := true;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Clear ;
end;
procedure TForm1.ICMPReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime: string;
begin
//檢測Ping的回復錯誤
if (AReplyStatus.MsRoundTripTime = 0 ) then
sTime := '<1'
else
sTime := '=';
//在列表框中顯示Ping消息
ListBox1.Items.Add(Format('ICMP_SEQ=%d Reply from %s [%s] : Bytes=%d time%s%d ms TTL=%d',
[AReplyStatus.SequenceId,
Edit1.Text,
AReplyStatus.FromIpAddress,
AReplyStatus.BytesReceived,
sTime,
AReplyStatus.MsRoundTripTime,
AReplyStatus.TimeToLive]));
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -