我想做一个程序就是判断当前计算机有没有连接到网络,主要是物理连网.有没有插网线,如果用InternetConnected 方法的话很不稳定,有时根本达不到效果,我也不知道为什么~~想请教一下有用过idicmpclient这个控件的大侠帮忙一下,该控件的主要方法及实现过程~~~谢谢了~!

解决方案 »

  1.   

    IdIcmpClient1.Host := '127.0.0.1';
    IdIcmpClient.Ping;在OnReply事件中判断返回值例如:procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
      const AReplyStatus: TReplyStatus);
    begin
      Memo1.Lines.Add(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;