关于delphi中利用IdIcmpClient空间实现ping命令 DelphiStringinterface类ping 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdBaseComponent, IdComponent, IdRawBase, IdRawClient, IdIcmpClient, ExtCtrls, ComCtrls, StdCtrls;type TForm1 = class(TForm) Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label1: TLabel; Edit1: TEdit; Button1: TButton; Edit2: TEdit; Memo1: TMemo; Button2: TButton; Memo2: TMemo; Edit3: TEdit; UpDown1: TUpDown; Button3: TButton; Timer1: TTimer; IdIcmpClient1: TIdIcmpClient; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure IdIcmpClient1Reply(ASender: TComponent; const AReplyStatus: TReplyStatus); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin Button1.Enabled := False; Timer1.Interval := UpDown1.Position * 1000; //设置循环时间 Timer1.Enabled := True; //开始循环end;procedure TForm1.FormCreate(Sender: TObject);begin //通常在窗体建立的时候我们可以设置一些组件的属性。 Memo1.ScrollBars := ssVertical; //显示垂直滚动条 Memo1.Color := clBlack; Memo1.Font.Color := clWhite; Memo2.Font.Color := clRed; Memo2.ScrollBars := ssVertical; Timer1.Enabled := False; UpDown1.Associate := Edit2; //关联到Edit2 UpDown1.Min := 1; //从1秒开始 UpDown1.Position := 5; //默认5秒end;procedure TForm1.Button2Click(Sender: TObject);begin Timer1.Enabled := False; Button1.Enabled := True;end;procedure TForm1.Button3Click(Sender: TObject);begin Close;end;procedure TForm1.Timer1Timer(Sender: TObject);begin try IdIcmpClient1.Host := Edit1.Text; IdIcmpClient1.Ping; //开始Ping操作 except Timer1.Enabled := False; //非法错误停止循环 Button1.Enabled := True; end;end;procedure TForm1.IdIcmpClient1Reply(ASender: TComponent; const AReplyStatus: TReplyStatus);var sTime: string; AMemo: TMemo; //当前添加内容的Memo组件begin if (AReplyStatus.MsRoundTripTime = 0) then sTime := '<1' else sTime := '='; //超时Memo2显示,正常状态Memo1显示 if (AReplyStatus.MsRoundTripTime > StrToIntDef(Edit3.Text, 1000)) then AMemo := Memo2 else AMemo := Memo1; AMemo.Lines.Add(Format('%s Reply from %s: bytes=%d time%s%dms TTL=%d', [ DatetimeToStr(now), AReplyStatus.FromIpAddress, AReplyStatus.BytesReceived, sTime, AReplyStatus.MsRoundTripTime, AReplyStatus.TimeToLive ]));end;end.看这个源码吧。 不停的ping啊?一点延时都没有! S:='ping -n 20 192.168.1.100'; WinExec( pchar(S),SW_SHOW);这样,也可以。 XE5 ping出现 10040错误信息 我也是在xe5执行ping的时候出现Error 10040 的错误,找了好几久都没找到问题只是发现出现那错误的时候应该是能ping的通,ping的通的时候不会出错! XE5下出现这个问题,一直没解决,加上参数:ICMP.ping('12345678901234567890123456789012',4);当能拼通时正常,拼不通时内存异常,晕死 拼不通时出现:access violation at oxoo4052ed:read of address ox3433322c. XE5下出现这个问题,一直没解决,加上参数:ICMP.ping('12345678901234567890123456789012',4);当能拼通时正常,拼不通时内存异常,晕死 我用一个ICMP实例,拼不同的IP就会出现内存冲突的异常每拼一个IP都得创建一个ICMP才行。 F1book问题请大家帮忙 delphi7.0 和 delphi V7.0 是同一个版本吗,他们有什么区别? 修改listview中columns选项问题 哪位有passcal的从入门到精通的书呀? word、execl、zip/rar文件怎样保存 Memo字段的操作问题! 关于Web Browser的简单问题 为什么同样的程序在我的DHEPHI里运行就不行? 如何在局域网访问不共享文件? 浏览器左边出现有文件树的窗口的做法?急! 为什么我的ADOQuery数据集没有filedbyname这个属性 delphi 引入wsdl文件 怎么更新?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdRawBase, IdRawClient,
IdIcmpClient, ExtCtrls, ComCtrls, StdCtrls;type
TForm1 = class(TForm)
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
Memo1: TMemo;
Button2: TButton;
Memo2: TMemo;
Edit3: TEdit;
UpDown1: TUpDown;
Button3: TButton;
Timer1: TTimer;
IdIcmpClient1: TIdIcmpClient;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Enabled := False;
Timer1.Interval := UpDown1.Position * 1000; //设置循环时间
Timer1.Enabled := True; //开始循环
end;procedure TForm1.FormCreate(Sender: TObject);
begin
//通常在窗体建立的时候我们可以设置一些组件的属性。
Memo1.ScrollBars := ssVertical; //显示垂直滚动条
Memo1.Color := clBlack;
Memo1.Font.Color := clWhite;
Memo2.Font.Color := clRed;
Memo2.ScrollBars := ssVertical;
Timer1.Enabled := False;
UpDown1.Associate := Edit2; //关联到Edit2
UpDown1.Min := 1; //从1秒开始
UpDown1.Position := 5; //默认5秒
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled := False;
Button1.Enabled := True;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
try
IdIcmpClient1.Host := Edit1.Text;
IdIcmpClient1.Ping; //开始Ping操作
except
Timer1.Enabled := False; //非法错误停止循环
Button1.Enabled := True;
end;
end;procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime: string;
AMemo: TMemo; //当前添加内容的Memo组件
begin
if (AReplyStatus.MsRoundTripTime = 0) then
sTime := '<1'
else
sTime := '=';
//超时Memo2显示,正常状态Memo1显示
if (AReplyStatus.MsRoundTripTime > StrToIntDef(Edit3.Text, 1000)) then
AMemo := Memo2 else
AMemo := Memo1;
AMemo.Lines.Add(Format('%s Reply from %s: bytes=%d time%s%dms TTL=%d', [
DatetimeToStr(now),
AReplyStatus.FromIpAddress,
AReplyStatus.BytesReceived,
sTime,
AReplyStatus.MsRoundTripTime,
AReplyStatus.TimeToLive
]));
end;end.
看这个源码吧。
WinExec( pchar(S),SW_SHOW);
这样,也可以。
只是发现出现那错误的时候应该是能ping的通,ping的通的时候不会出错!
ICMP.ping('12345678901234567890123456789012',4);
当能拼通时正常,拼不通时内存异常,晕死
ICMP.ping('12345678901234567890123456789012',4);
当能拼通时正常,拼不通时内存异常,晕死
我用一个ICMP实例,拼不同的IP就会出现内存冲突的异常
每拼一个IP都得创建一个ICMP才行。