请问如何监听ICMP报文?? 或者说如何检查收到的IP报文看看是否是ping程序发来的ICMP报文提取出其ip 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 据说VC可以!DELPHI的不知道!学习 unit ping;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, IdBaseComponent, IdComponent, IdRawBase, IdRawClient, IdIcmpClient;type TPingFrm = class(TForm) ICMP: TIdIcmpClient; Panel1: TPanel; Button1: TButton; Button2: TButton; Edit1: TEdit; Label1: TLabel; ListBox1: TListBox; procedure Button2Click(Sender: TObject); procedure ICMPReply(ASender: TComponent; const AReplyStatus: TReplyStatus); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var PingFrm: TPingFrm;implementation{$R *.dfm}procedure TPingFrm.Button2Click(Sender: TObject);beginListBox1.Clear ;end;procedure TPingFrm.ICMPReply(ASender: TComponent; const AReplyStatus: TReplyStatus);varsTime: string;beginif AReplyStatus.ReplyStatusType=rsError then showmessage('hello*');if (AReplyStatus.MsRoundTripTime = 0 ) thensTime := '<1'elsesTime := '=';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;procedure TPingFrm.Button1Click(Sender: TObject);vari : integer;beginICMP.Host := Edit1.Text ;ICMP.ReceiveTimeout := 1000;Button1.Enabled := false;tryfor i:=0 to 3 dobeginICMP.Ping ;Application.ProcessMessages ;end;except on e:exception do showmessage('hlo*') ;end;finallyButton1.Enabled := true;end;end;end. 模糊查找,语句错误,求救 Delphi窗体移动问题 大家帮忙,我想写个小程序。 我又写了一个小工具《VCL继承图1.0》大家一起玩玩~~ 关于 RichEdit,来者有分 如何监视和反监视其他程序的smtp发信!!!!!!!!!!!!!!!!!! 请教编程高手一个问题 如何实现API背景音乐播放? 怎样得到一天的起始时间,例如:今天是2001-11-1,则我希望得到:2001-11-1 00:00:00 关于线程的问题啊? 数据库问题 吉旭是一家珠宝软件公司
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IdBaseComponent, IdComponent, IdRawBase,
IdRawClient, IdIcmpClient;type
TPingFrm = class(TForm)
ICMP: TIdIcmpClient;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Label1: TLabel;
ListBox1: TListBox; procedure Button2Click(Sender: TObject);
procedure ICMPReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
PingFrm: TPingFrm;implementation{$R *.dfm}
procedure TPingFrm.Button2Click(Sender: TObject);
begin
ListBox1.Clear ;
end;procedure TPingFrm.ICMPReply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime: string;
begin
if AReplyStatus.ReplyStatusType=rsError then showmessage('hello*');
if (AReplyStatus.MsRoundTripTime = 0 ) then
sTime := '<1'
else
sTime := '=';
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;procedure TPingFrm.Button1Click(Sender: TObject);
var
i : integer;
begin
ICMP.Host := Edit1.Text ;
ICMP.ReceiveTimeout := 1000;
Button1.Enabled := false;
try
for i:=0 to 3 do
begin
ICMP.Ping ;
Application.ProcessMessages ;
end;
except
on e:exception do showmessage('hlo*') ;
end;
finally
Button1.Enabled := true;
end;
end;
end.