Delphi 版的 Ping
程序员文章站
2022-07-13 23:47:00
...
uses IdIcmpClient;
{ Delphi 版的 Ping }
function DPingIP(const strIP: string; const intLinkTimeOut: Integer): Boolean;
var
icmp: TIdIcmpClient;
rpss: TReplyStatus;
begin
icmp := TIdIcmpClient.Create(nil);
try
icmp.Host := strIP;
icmp.ReceiveTimeout := intLinkTimeOut;
try
icmp.Ping;
rpss := icmp.ReplyStatus;
Result := not(rpss.ReplyStatusType = rsTimeOut);
except
Result := False;
end;
finally
icmp.Free;
end;
end;
上一篇: Linux 之ping功能实现详解
下一篇: Java单例模式