Delphi Ping 返回通或不通
2015-11-23 09:01
513 查看
function pingf (ip :string):string;
var
ReplyStatus:TReplyStatus;
ICMP:TIdIcmpClient;
begin
ICMP:= TIdIcmpClient.Create(nil );
ICMP.ReceiveTimeout := 1000;
ICMP.Host := ip;
try
ICMP.Ping;
ReplyStatus:=icmp.ReplyStatus;
//Result:= TStringList.Create;
//if (ReplyStatus.MsRoundTripTime = 0) then
//Result.add('<1')
//else Result.add(Format('%d',[ReplyStatus.MsRoundTripTime]));
//Result.add(Format('%d',[ ReplyStatus.TimeToLive]));
if (ReplyStatus.MsRoundTripTime = 0) then
Result := '<1'
else
Result := Format('%d',[ReplyStatus.MsRoundTripTime]);
except
Result := '';
end;
ICMP.free;
end;
經本人測試,調用 返回等‘’或'1000' 則爲Ping 不通
var
ReplyStatus:TReplyStatus;
ICMP:TIdIcmpClient;
begin
ICMP:= TIdIcmpClient.Create(nil );
ICMP.ReceiveTimeout := 1000;
ICMP.Host := ip;
try
ICMP.Ping;
ReplyStatus:=icmp.ReplyStatus;
//Result:= TStringList.Create;
//if (ReplyStatus.MsRoundTripTime = 0) then
//Result.add('<1')
//else Result.add(Format('%d',[ReplyStatus.MsRoundTripTime]));
//Result.add(Format('%d',[ ReplyStatus.TimeToLive]));
if (ReplyStatus.MsRoundTripTime = 0) then
Result := '<1'
else
Result := Format('%d',[ReplyStatus.MsRoundTripTime]);
except
Result := '';
end;
ICMP.free;
end;
經本人測試,調用 返回等‘’或'1000' 則爲Ping 不通
相关文章推荐
- Delphi Windows API判断文件共享锁定状态(OpenFile和CreateFile两种方法)
- 一直用delphi做ERP软件,想换个语言,想做java,但是。。好纠结啊
- delphi7编程技巧
- Delphi自带的的Zip比较好用简单
- Delphi书籍推荐
- delphi下的office编辑
- delphi事务处理
- delphi 做了个DLL
- 将DelphiZXIngQRCode改造成拖到窗口上就能用的TZXingQRCodeLi二维码控件
- Delphi 函数嵌套 定义与调用
- Delphi 取得 iOS 辅助使用里的字型大小
- Delphi合并2个动态数组
- Delphi之使用资源文件(Using Resource Files)
- 开发一个delphi写的桌面图标管理代码
- delphi property 实例(包含数组属性)
- delphi实现托盘
- delphi 窗体自适应屏幕分辨率
- delphi 处理图片(剪切,压缩)
- Delphi中怎么结束线程(这个线程是定时执行的)(方案二)
- Delphi中怎么结束线程(这个线程是定时执行的)(方案一)