我没有网卡,winsock1.localip = 拨号上网的动态 ip 。

解决方案 »

  1.   

    winsock1.localip=拨号上网的动态 ip 。 是要出错的,此属性好象不能赋值。
      

  2.   

    用API函数吧,我替你写了一个getmyip函数:
    好象分太少了:( 
    Public Declare Function gethostbyname Lib "WSOCK32.DLL" _
       (ByVal szHost As String) As Long
    Public Declare Sub RtlMoveMemory Lib "kernel32" _
    (hpvDest As Any, _
        ByVal hpvSource As Long, _
        ByVal cbCopy As Long)Private Function GetMyIP() As String
       Dim hostname As String * 256
       Dim hostent_addr As Long
       Dim host As HOSTENT
       Dim hostip_addr As Long
       Dim temp_ip_address() As Byte
       Dim I As Integer
       Dim ip_address As String
       ReDim MyIP(4)
            If gethostname(hostname, 256) = SOCKET_ERROR Then
               MsgBox "Windows Sockets error " & Str(WSAGetLastError())
           Else
               hostname = Trim$(hostname)
           End If
            hostent_addr = gethostbyname(hostname)
            If hostent_addr = 0 Then
               MsgBox "Winsock.dll is not responding."
           End If
            RtlMoveMemory host, hostent_addr, LenB(host)
           RtlMoveMemory hostip_addr, host.hAddrList, 4
     
           ReDim temp_ip_address(1 To host.hLen)
           RtlMoveMemory temp_ip_address(1), hostip_addr, host.hLen
     
           For I = 1 To host.hLen
               ip_address = ip_address & temp_ip_address(I) & "."
               MyIP(I) = temp_ip_address(I)
           Next
           ip_address = Mid$(ip_address, 1, Len(ip_address) - 1)
           GetMyIP = ip_address
    End Function
      

  3.   

    我都有这代码了,问题是怎么取出所有的ip(局域网的和动态的),host.hAddrList的返回值中 ip是怎么间隔的,怎么分割的问题。
      

  4.   

    lou_df说得对,没有网卡时取出的localip就是动态的ip
      

  5.   

     你先用RasGetProjectionInfo函数得到动态IP,剩下的不就是局域网IP了。
    不会得动态IP,去看看http://go3.163.com/_NTES/~delphi6/doc/internet/tel_ip.htm