如果有,是什么?

解决方案 »

  1.   

    function FindComputer(ComputerName: string);
    var
      WSAData: TWSAData;
      HostEnt: PHostEnt;
    begin
      Result := False;
      WSAStartup(2, WSAData);
      HostEnt := gethostbyname(PChar(ComputerName));
      if HostEnt = nil then Result := False;
      WSACleanup;
    end;
      

  2.   

    有啊,但ping是一种网络协议,可不是一两个API就可以完事的哟!它涉及到一整套的通讯过程.我原来写过这样的帖子,你可以去看看:
    http://delphijl.99898.com/delphier/article/ShowArticle.asp?ArticleID=18
    或者写信给我:[email protected]
      

  3.   

    unit Tping;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls, shellapi, Sockets, WInSock, IdBaseComponent,
      IdComponent, IdRawBase, IdRawClient, IdIcmpClient;type
        TMyPing = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Edit1: TEdit;
        IdIcmpClient1: TIdIcmpClient;
        ListBox1: TListBox;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure IdIcmpClient1Reply(ASender: TComponent;
          const AReplyStatus: TReplyStatus);  private
        { Private declarations }
      public
        { Public declarations }
      end;var
      MyPing: TMyPing;implementation{$R *.dfm}procedure TMyPing.Button1Click(Sender: TObject);
    var
     i : integer;
    begin
      IdIcmpClient1.Host:= Edit1.Text; //宿主计算机的名称或IP地址
      IdIcmpClient1.ReceiveTimeout:=1000; //最大等待时间
      Button1.Enabled := false;
      try
       for i:=0 to 3 do //重复4次
       begin
         IdIcmpClient1.Ping('hello',0);
         Application.ProcessMessages ; //延时
       end;
      finally
       Button1.Enabled := true;
      end;
    end;procedure TMyPing.Button2Click(Sender: TObject);
    begin
    ListBox1.Clear ;
    end;procedure TMyPing.IdIcmpClient1Reply(ASender: TComponent;
      const AReplyStatus: TReplyStatus);
    var
     sTime: string;
    begin
     //检测Ping的回复错误
     if (AReplyStatus.MsRoundTripTime = 0 ) then
       sTime := '<1'
     else
       sTime := '=';
     //在列表框中显示Ping消息
     ListBox1.Items.Add(Format('Reply from [%s] : Bytes=%d time%s%d ms TTL=%d',
     [AReplyStatus.FromIpAddress,
     AReplyStatus.BytesReceived,
     sTime,
     AReplyStatus.MsRoundTripTime,
     AReplyStatus.TimeToLive]));
    end;
    end.
      

  4.   

    同一楼上,打开TIdIcmpClient的源码看看!