http://expert.csdn.net/Expert/topic/817/817759.xml?temp=8.111209E-02

解决方案 »

  1.   

    對,這個網站好
    www.allapi.com
      

  2.   

    给你个简单的:
       Public Function GetIPAddress() As String
        
        Dim sHostName As String * 256
        Dim lpHost As Long
        Dim HOST As HOSTENT
        Dim dwIPAddr As Long
        Dim tmpIPAddr() As Byte
        Dim i As Integer
        Dim sIPAddr As String
         
        If gethostname(sHostName, 256) <> 0 Then
            GetIPAddress = ""
            MsgBox "    取本机IP地址出错!", vbInformation + vbOKCancel, "严重错误"
            Exit Function
        End If
        
        sHostName = Trim(sHostName)
        lpHost = gethostbyname(sHostName)
        If lpHost = 0 Then
            GetIPAddress = ""
            MsgBox "Windows Sockets are not responding. " & "Unable to successfully get Host Name."
            Exit Function
        End If
        
        CopyMemoryIP HOST, lpHost, Len(HOST)
        CopyMemoryIP dwIPAddr, HOST.hAddrList, 4
        ReDim tmpIPAddr(1 To HOST.hLen)
        CopyMemoryIP tmpIPAddr(1), dwIPAddr, HOST.hLen
        For i = 1 To HOST.hLen
            sIPAddr = sIPAddr & tmpIPAddr(i) & "."
        Next
        GetIPAddress = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)
    End Function