我已知了一个IP地址,在局域网中如何知道此IP地址的机器是否连接在局域网中(有放火墙的哟),我尝试用Ping命令,它返回值认为不在网,可实质是在的呀,所以请求其他方法。谢谢了。

解决方案 »

  1.   

    找一个根据IP地址获取MAC地址的代码, 如果能获取MAC地址, 说明这个IP地址的主机在线。
      

  2.   

    http://www.delphibox.com/article.asp?articleid=327
      

  3.   

    procedure CheckLanIP(strIP:string);
    var
      ipaddress:dword;
      hos:phostent;begin
       ipaddress:=  inet_addr(PChar(strip));
       hos:=gethostbyaddr(@ipaddress,sizeof(ipaddress),PF_INET);
       if hos<>nil then   ShowMessage( 'The Computer Named '''+hos.h_name+''' is Online')
       else
       begin
          case wsagetlasterror of
               WSANOTINITIALISED:
                  ShowMessage('A successful WSAStartup must occur before using this function.');
               WSAENETDOWN:
                ShowMessage('The network subsystem has failed.');
               WSAHOST_NOT_FOUND:
                ShowMessage('Authoritative Answer Host not found.');
               WSATRY_AGAIN:
                ShowMessage('Non-Authoritative Host not found, or server failed.');
               WSANO_RECOVERY:
                ShowMessage('Nonrecoverable error occurred.');
               WSANO_DATA:
                    ShowMessage('The Computer is Offline.');
                //ShowMessage('Valid name, no data record of requested type.');
               WSAEINPROGRESS:
                ShowMessage('A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.');
               WSAEAFNOSUPPORT:
                    ShowMessage('The type specified is not supported by the Windows Sockets implementation.');
               WSAEFAULT:
                    ShowMessage('The addr argument is not a valid part of the user address space, or the len argument is too small.');
               WSAEINTR:
                ShowMessage('The (blocking) call was canceled through WSACancelBlockingCall.');
           end;
       end;end;
      

  4.   

    可能是防火墙的原因,把要PING的机器的防火墙关掉试试!
      

  5.   

    有的防火墙的设置是可以不让任何机器Ping到的!
      

  6.   

    [TO unsigned(僵哥)]
    我试过了,可怎么返回都是为空?我用Ping命令还有些是连接成功的哟。好奇怪的也