例如
ping 21cn.com还有怎么得到返回的 time 值是多少????如果丢包怎么返回变量???

解决方案 »

  1.   

    用TIdIcmpClientprocedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
      const AReplyStatus: TReplyStatus);
    begin
      Memo1.Lines.Add(Self.IdIcmpClient1.Host);
      Memo1.Lines.Add(Format('FromIpAddress: %s, BytesReceived: %d, MsgType: %d, '
        + 'MsRoundTripTime: %d, SequenceId: %d, TimeToLive: %d, ReplyStatusType: %d', [
        AReplyStatus.FromIpAddress,
        AReplyStatus.BytesReceived,
        AReplyStatus.MsgType,
        AReplyStatus.MsRoundTripTime,
        AReplyStatus.SequenceId,
        AReplyStatus.TimeToLive,
        Integer(AReplyStatus.ReplyStatusType)
      ]));
    end;
      

  2.   

    那么 在哪里加入变量 21cn.com ????
      

  3.   

    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
      IdIcmpClient1.Host := 'www.google.com';
      IdIcmpClient1.Ping;end;procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
      const AReplyStatus: TReplyStatus);
    begin
      Memo1.Lines.Add(Self.IdIcmpClient1.Host);
      Memo1.Lines.Add(Format('FromIpAddress: %s, BytesReceived: %d, MsgType: %d, '
        + 'MsRoundTripTime: %d, SequenceId: %d, TimeToLive: %d, ReplyStatusType: %d', [
        AReplyStatus.FromIpAddress,
        AReplyStatus.BytesReceived,
        AReplyStatus.MsgType,
        AReplyStatus.MsRoundTripTime,
        AReplyStatus.SequenceId,
        AReplyStatus.TimeToLive,
        Integer(AReplyStatus.ReplyStatusType)
      ]));
    end;