Delphi Ping

Posted cipherlab

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Delphi Ping相关的知识,希望对你有一定的参考价值。

function PingServer(HostIP: string;LinkTimeOut: integer): boolean;
var
  RRemoteC: TIdIcmpClient;
  AReplyStatus: TReplyStatus;
begin
  try
    result := true;
    RRemoteC := TIdIcmpClient.Create(nil);
    RRemoteC.Host := HostIP;
    RRemoteC.ReceiveTimeout := LinkTimeOut;
    try
      RRemoteC.Ping;
      AReplyStatus := RRemoteC.ReplyStatus;
      if (AReplyStatus.ReplyStatusType = rsTimeOut) then
      begin
        result := false;
      end;
    except
      result := false;
    end;
  finally
    RRemoteC.Free;
  end;
end;

  

以上是关于Delphi Ping的主要内容,如果未能解决你的问题,请参考以下文章