使用GetHst控件。http://ftp.componentsource.com/KITS/00004600.EXE

解决方案 »

  1.   

    利用以下代码:(在窗体中放入一个按钮(NAME:CMDCONNECT)和一个WINSOCK控件)
    Option Explicit
    Const EchoPort = 80
    Private Sub cmdConnect_Click()
        Dim temp As String
        temp = InputBox$("Enter a server name...", _
            "Connect to the Echo Service", Winsock1.RemoteHost)
        If temp <> "" Then
            If Winsock1.State <> sckClosed Then Winsock1.Close
                Winsock1.RemoteHost = temp
                Winsock1.RemotePort = EchoPort
                Winsock1.LocalPort = 0
                Winsock1.Connect
             End If
    End Sub
    Private Sub Winsock1_Connect()
        MsgBox Winsock1.RemoteHostIP
    End Sub
    运行一下看,发现了什么!!!
      

  2.   

    '在bas中
    ' WSock32 UDTsType Inet_address
        Byte4 As String * 1
        Byte3 As String * 1
        Byte2 As String * 1
        Byte1 As String * 1
    End TypePublic IPLong As Inet_addressType Hostent
        h_name As Long
        h_aliases As Long
        h_addrtype As Integer
        h_length As Integer
        h_addr_list As Long
    End Type
    Declare Function gethostbyname& Lib "wsock32.dll" (ByVal hostname$)
    Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As _ Any, hpvSource As Any, ByVal cbCopy As Long)
    在Form中:
    dim PointerToPointer As Long
    dim ListAddress As Long
    Dim Addr As Long
    If gethostbyname("www.sohu.com") = SOCKET_ERROR Then   
            MsgBox "未找到此地址,请检查网络是否已经连通.", vbOKOnly, "错误"
        Else
            PointerToPointer = gethostbyname("www.sohu.com")               
            CopyMemory Hostent.h_name, ByVal _
            PointerToPointer, Len(Hostent)                              ListAddress = Hostent.h_addr_list                   
            CopyMemory ListAddr, ByVal ListAddress, 4           
            CopyMemory IPLong, ByVal ListAddr, 4            
            CopyMemory Addr, ByVal ListAddr, 4        IP地址 = CStr(Asc(IPLong.Byte4)) + "." + CStr(Asc(IPLong.Byte3)) _
                + "." + CStr(Asc(IPLong.Byte2)) + "." + CStr(Asc(IPLong.Byte1))
        End If
    如果你需要完整的Ping程序,我可以提供。
      

  3.   

    chen_lin:  我急需完整的Ping程序,能否提供???