- 博客(0)
- 资源 (5)
- 收藏
- 关注
DELPHI 实现ping功能
实现PING功能
With ICMP.ReplyStatus do
begin
Msg:='Reply from'+' '+edthost.Text;
Msg:=Msg+' '+'bytes='+IntToStr(BytesReceived); //返回字节数
Msg:=Msg+' '+'TTL='+IntToStr(TimeToLive); //返回生存时间
Tm:=MsRoundTripTime; //返回执行时间
if Tm<1 then Tm:=1;
Msg:=Msg+' '+'time='+IntToStr(Tm)+'ms';
lstlnfo.Items.Add(Msg);//保存信息
if (BytesReceived=0) or (TimeToLive=0) then
begin //无数据返回
b:=b+1; //记录掉包数量
lstlnfo.ItemIndex:=lstlnfo.Items.Count-1;
end;
//if lstlnfo.Count>100 then lstlnfo.Clear;
if i mod 100=0 then stat1.SimpleText:='Lost:'+IntToStr(b)+ '/'+IntToStr(i)+'='+copy(FloatToStr(b/i*1000),1,4)+'‰'; //每Ping到100次显示一次掉包情况
end;
2008-12-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人