Results 1 to 6 of 6

Thread: HELP: Multiple IP Address

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    4

    Exclamation

    Hello all,

    I have a NIC and a modem. I use the modem to connect to the internet, as below:
    Code:
    Windows 2000 IP Configuration
    
            Host Name . . . . . . . . . . . . : zlg
            Primary DNS Suffix  . . . . . . . :
            Node Type . . . . . . . . . . . . : Mixed
            IP Routing Enabled. . . . . . . . : Yes
            WINS Proxy Enabled. . . . . . . . : No
    
    Ethernet adapter Local Area Connection:
    
            Connection-specific DNS Suffix  . :
            Description . . . . . . . . . . . : Winbond W89C940 PCI Ethernet Adapter
            Physical Address. . . . . . . . . : 
            DHCP Enabled. . . . . . . . . . . : No
            IP Address. . . . . . . . . . . . : 192.168.0.1
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . :
            DNS Servers . . . . . . . . . . . :
            NetBIOS over Tcpip. . . . . . . . : Disabled
    
    PPP adapter StarHub Free Internet:
    
            Connection-specific DNS Suffix  . :
            Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface
            Physical Address. . . . . . . . . : 
            DHCP Enabled. . . . . . . . . . . : No
            IP Address. . . . . . . . . . . . : 203.117.123.170
            Subnet Mask . . . . . . . . . . . : 255.255.255.255
            Default Gateway . . . . . . . . . : 203.117.123.170
            DNS Servers . . . . . . . . . . . : 203.117.33.19
                                                203.117.33.18
            NetBIOS over Tcpip. . . . . . . . : Disabled

    Question: When I use Winsock control in vb to detect the ip address, all it give me is the one for Ethernet adapter Local Area Connection. Any idea how to make it so that I can obtain the one for PPP adapter StarHub Free Internet???





    THANX!



    Sze Leung

    [Edited by zlg on 01-16-2001 at 08:16 AM]

  2. #2
    New Member
    Join Date
    Nov 2000
    Location
    UK
    Posts
    4

    Talking I have had this problem also.

    Right, I have had this problem, and it was not the easiest one to solve. Firstly I trust the command that you are using to retrieve the IP address is something like:

    text1.text=winsock1.localIP

    right, now this will retrive your Nic IP, (but im sure that you will know that already). Right, now in order to solve the problem you will need to manipulate the registry, as the winsock control will not do it, as the NiC takes preference.

    Right, before you do anything, you need to know how to retrieve data from the registry, there is info about this on vb-world (though I cant remember where, sorry!).

    Now connect to the internet, I understand your using Windows NT 5.0 (2000) thats good, right you need to find your IP before you start, the best way is connect to an Irc server which will tell you your address, eg 62.255.212.111

    Now you have founf this, goto Start -> run and type in regedit

    Once it opens search the registry for that IP, and it should locate the data in HKEY_Local_Machine -> and in the Winsocks5 sub directory (I think) though im not at home right now so I cant be fully sure :-).

    Basically, although the exact locations are vague that is how to do it. I have done the same thing on Windows NT 4.0 and im betting that the two are not dis-similar.

    If you would like a sample programme of how to do this, I would be happy to send you the one that I have created, if you send me an email at:

    <a href="mailto:[email protected]?subject=the two ip's">[email protected]</a>

    Hope this was reasonably helpful.

    =A

    MS Basic isnt basic, its an illusion I tell you a lie, dont believe it!

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    4

    Talking

    Thanx for the help, but i think i would rather not touch the reg.

    I found another stack of codes, WHICH I DUN UNDERSTAND AT ALL...

    Here goes...

    Code:
    'MICROSOFT MSDN
    
    Option Explicit
    
    Private Const WS_VERSION_REQD = &H101
    Private Const WS_VERSION_MAJOR = WS_VERSION_REQD \ &H100 And &HFF&
    Private Const WS_VERSION_MINOR = WS_VERSION_REQD And &HFF&
    Private Const MIN_SOCKETS_REQD = 1
    Private Const SOCKET_ERROR = -1
    Private Const WSADescription_Len = 256
    Private Const WSASYS_Status_Len = 128
    Private Const strWinsockNotResponding As String = "Winsock.dll is not responding"
    Private Const strWinsockError As String = "Windows Sockets error "
    Private Const strCouldNotGetIP As String = "Could not start Winsock services"
    
    Private Type HOSTENT
        hName As Long
        hAliases As Long
        hAddrType As Integer
        hLength As Integer
        hAddrList As Long
    
    End Type
    
    Private Type WSADATA
        wversion As Integer
        wHighVersion As Integer
        szDescription(0 To WSADescription_Len) As Byte
        szSystemStatus(0 To WSASYS_Status_Len) As Byte
        iMaxSockets As Integer
        iMaxUdpDg As Integer
        lpszVendorInfo As Long
    
    End Type
    
    Private Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Long
    Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Integer, lpWSAData As WSADATA) As Long
    Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
    Private Declare Function gethostname Lib "WSOCK32.DLL" (ByVal hostname$, ByVal HostLen As Long) As Long
    Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname$) As Long
    Private Declare Sub RtlMoveMemory Lib "KERNEL32" (hpvDest As Any, ByVal hpvSource&, ByVal cbCopy&)
    
    Function hibyte(ByVal wParam As Integer)
        hibyte = wParam \ &H100 And &HFF&
    
    End Function
    
    Function lobyte(ByVal wParam As Integer)
        lobyte = wParam And &HFF&
    
    End Function
    
    Function SocketsInitialize() As String
    Dim WSAD As WSADATA
    Dim iReturn As Integer
    Dim sLowByte, sHighbyte, sMsg As String
    
        iReturn = WSAStartup(WS_VERSION_REQD, WSAD)
    
        If iReturn <> 0 Then
            SocketsInitialize = strWinsockNotResponding
            Exit Function
        
        End If
    
        If lobyte(WSAD.wversion) < WS_VERSION_MAJOR Or (lobyte(WSAD.wversion) = _
            WS_VERSION_MAJOR And hibyte(WSAD.wversion) < WS_VERSION_MINOR) Then
    
            sHighbyte = Trim$(Str$(hibyte(WSAD.wversion)))
            sLowByte = Trim$(Str$(lobyte(WSAD.wversion)))
            SocketsInitialize = "Windows Sockets version " & sLowByte & "." & sHighbyte & _
            " is not supported by winsock.dll "
            Exit Function
        
        End If
    
        'iMaxSockets is not used in winsock 2. So the following check is only
        'necessary for winsock 1. If winsock 2 is requested,
        'the following check can be skipped.
    
        If WSAD.iMaxSockets < MIN_SOCKETS_REQD Then
            SocketsInitialize = "This application requires a minimum of " & _
            Trim$(Str$(MIN_SOCKETS_REQD)) & " supported sockets."
            Exit Function
        
        End If
        
        SocketsInitialize = ""
    
    End Function
    
    Function SocketsCleanup() As String
        Dim lReturn As Long
    
        lReturn = WSACleanup()
    
        If lReturn <> 0 Then
            SocketsCleanup = "Socket error " & Trim$(Str$(lReturn)) & " occurred in Cleanup "
            Exit Function
        
        End If
    
    End Function
    
    Public Function GetLocalIPAddress(strIPAddresses() As String) 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
        Dim intCounter As Integer
        Dim strErrorMessage As String
    
        strErrorMessage = SocketsInitialize
        
        If strErrorMessage = "" Then
            If gethostname(hostname, 256) = SOCKET_ERROR Then
                GetLocalIPAddress = strWinsockError & Str(WSAGetLastError())
                Exit Function
            
            Else
                hostname = Trim$(hostname)
            
            End If
            
            hostent_addr = gethostbyname(hostname)
            
            If hostent_addr = 0 Then
                GetLocalIPAddress = strWinsockNotResponding
                Exit Function
                
            End If
            
            RtlMoveMemory host, hostent_addr, LenB(host)
            RtlMoveMemory hostip_addr, host.hAddrList, 4
            
            'get all of the IP address if machine is  multi-homed
        
            Do
                ReDim temp_ip_address(1 To host.hLength)
                RtlMoveMemory temp_ip_address(1), hostip_addr, host.hLength
                
                For i = 1 To host.hLength
                    ip_address = ip_address & temp_ip_address(i) & "."
                
                Next
                
                ip_address = Mid$(ip_address, 1, Len(ip_address) - 1)
                ReDim Preserve strIPAddresses(intCounter)
                strIPAddresses(intCounter) = ip_address
                
                ip_address = ""
                host.hAddrList = host.hAddrList + LenB(host.hAddrList)
                RtlMoveMemory hostip_addr, host.hAddrList, 4
                
                intCounter = intCounter + 1
            
            Loop While (hostip_addr <> 0)
         
            SocketsCleanup
            GetLocalIPAddress = ""
        
        Else
            GetLocalIPAddress = strErrorMessage
        
        End If
    
    End Function
    
    ' Returns the user's Internet address, not one from his local pool of IP addresses (if
    ' the user has some LAN cards and/or a modem).
    Public Function GetInternetAddress() As String
        Dim strAllIPAddresses() As String
        DoEvents
        If GetLocalIPAddress(strAllIPAddresses()) = "" Then
            GetInternetAddress = strAllIPAddresses(UBound(strAllIPAddresses()))
        Else
            GetInternetAddress = ""
        End If
    End Function
    
    
    
    Sub Main()
        MsgBox GetInternetAddress()
    End Sub

    Will someone please try to explain to me? I am just a miserable beginner...

  4. #4
    New Member
    Join Date
    Jan 2001
    Posts
    1
    Hiya

    well to be honest, and I don't mean this disrespectful, but if you're a beginner *and* this code works, use it and don't ask questions..

    As soon as u have an idea on how the API works and more stuff of the like, go look through the code again.

    Waxxx

    (If it workx, why fix it?)
    An Idle Mind Is The Devils Playground

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    4

    Cool

    I think i have some idea about how API work.

    API is something like a complied list of function...
    Include the (normally dll) file and define the function and you can use the function like any other.

    The thing i dun understand is how u people know what's inside a dll file? How do you know the names of the functions and what they do or what they return? Maybe there is an api reader of some sort...

    Please correct me if i am wrong or something.

    Thanx.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    4
    and by the way, is just-accept-facts-and-no-understand how u learn things?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width