Results 1 to 13 of 13

Thread: Finding the IP address of a machine.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Finding the IP address of a machine.

    How do I get the IP address of a machine using VB6 code?

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Finding the IP address of a machine.

    You can use:

    vb Code:
    1. Text1.Text = winsock.RemoteHostIP

    Although, how are you going to connect to the remote machine in the first place?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Finding the IP address of a machine.

    Quote Originally Posted by Nightwalker83 View Post
    You can use:

    vb Code:
    1. Text1.Text = winsock.RemoteHostIP

    Although, how are you going to connect to the remote machine in the first place?
    Actually, I want to get the IP address of the local machine.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Finding the IP address of a machine.

    Quote Originally Posted by svg3414 View Post
    Actually, I want to get the IP address of the local machine.
    Ah ok! In that case it is:

    vb Code:
    1. Private Sub Form_Load()
    2. Text1.Text = Winsock1.LocalIP
    3. End Sub
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Finding the IP address of a machine.

    The reality isn't so simple.

    An individual computer can have multiple adapters and each adapter can have multiple IP addresses. Which of these N * M addresses gets returned by the Winsock control depends on what actions have been performed on the control first (such as an action that specified which IP address to use).

    In the degenerate case you'll usually get the first (i.e. "preferred") one though, and in the extreme degenerate case of John Doe's home PC there is only one anyway.

    This is changing though. As more John Does out there start running VM software they'll find they have software adapters installed on their machines for bridging to VMs.


    But the funny part is, none of this may relate to the question that is trying to be asked here anyway. After all, knowing "your IP address" is generally pretty useless since you can use the loopback address for local operations.

    I suspect the OP here may be asking how to find his router's public IP address.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Finding the IP address of a machine.

    Quote Originally Posted by dilettante View Post
    The reality isn't so simple.
    ...........
    I suspect the OP here may be asking how to find his router's public IP address.
    Well I will clarify. The situation is something like this.

    My company has some 200 branches with some 1200 machines connected on a WAN. The Head Office will send periodical statements to the branches. When a statement arrives, a window will pop up on the branch machine and the user has to click a button. On clicking the button a message will be sent to the machine at Head Office which should contain the IP address of the machine. I hope it is clear now.

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Finding the IP address of a machine.

    Well then did the simple Winsock control approach resolve the question?

    If so you can mark this revolved via the Thread Tools menu above.

  8. #8
    Addicted Member Darren M.'s Avatar
    Join Date
    Nov 2005
    Location
    D/FW
    Posts
    200

    Re: Finding the IP address of a machine.

    Quote Originally Posted by svg3414 View Post
    Well I will clarify. The situation is something like this.

    My company has some 200 branches with some 1200 machines connected on a WAN. The Head Office will send periodical statements to the branches. When a statement arrives, a window will pop up on the branch machine and the user has to click a button. On clicking the button a message will be sent to the machine at Head Office which should contain the IP address of the machine. I hope it is clear now.
    That being the situation I might suggest the following, knowing the IP could change and it sounds like you want proof that a specific machine clicked ok. (e.g. IP addresses can/will probably change. DHCP and all...)

    Assuming the machine name would suffice you could easily use something like this.....
    vb Code:
    1. Private Sub Command1_Click()
    2.     Dim strMachineName  As String
    3.     strMachineName = Environ$("COMPUTERNAME")
    4.     ' Send your message here
    5. End Sub

    My attempt at a thought provoking sig.
    * Remove ALL assumptions. You'll probably find your problem.
    * New to the forums? READ THIS! The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft
    * Learn how to fish!
    * Subscribing to every thread I post in is like having a book mark in my mind. Every now and then I get to review a fond memory.
    * If you find my post helpful do me a 15 second favor and RATE it. (Rate Post. Over there <----)
    * Please mark all resolved threads as such. It makes searching for fixes SO much easier!
    * Have fun. We aren't on this rock for long, enjoy it.
    * Sometimes I'm wrong. When I am I admit it. Never am I malicious. If reading my post and you think otherwise, then it MAY be tongue in cheek. Read it again.

  9. #9
    Addicted Member Darren M.'s Avatar
    Join Date
    Nov 2005
    Location
    D/FW
    Posts
    200

    Re: Finding the IP address of a machine.

    I knew I had this code some where. I do not recall where I picked this up, I am not the author.

    So, just in case you MUST have the IP address.....
    vb Code:
    1. Option Explicit
    2.  
    3. Public Const MAX_WSADescription As Long = 256
    4. Public Const MAX_WSASYSStatus As Long = 128
    5. Public Const ERROR_SUCCESS       As Long = 0
    6. Public Const WS_VERSION_REQD     As Long = &H101
    7. Public Const WS_VERSION_MAJOR    As Long = WS_VERSION_REQD \ &H100 And &HFF&
    8. Public Const WS_VERSION_MINOR    As Long = WS_VERSION_REQD And &HFF&
    9. Public Const MIN_SOCKETS_REQD    As Long = 1
    10. Public Const SOCKET_ERROR        As Long = -1
    11.  
    12. Public Type HOSTENT
    13.    hName      As Long
    14.    hAliases   As Long
    15.    hAddrType  As Integer
    16.    hLen       As Integer
    17.    hAddrList  As Long
    18. End Type
    19.  
    20. Public Type WSADATA
    21.    wVersion      As Integer
    22.    wHighVersion  As Integer
    23.    szDescription(0 To MAX_WSADescription)   As Byte
    24.    szSystemStatus(0 To MAX_WSASYSStatus)    As Byte
    25.    wMaxSockets   As Integer
    26.    wMaxUDPDG     As Integer
    27.    dwVendorInfo  As Long
    28. End Type
    29.  
    30. Public Declare Function WSAGetLastError Lib "wsock32" () As Long
    31.  
    32. Public Declare Function WSAStartup Lib "wsock32" _
    33.   (ByVal wVersionRequired As Long, _
    34.    lpWSADATA As WSADATA) As Long
    35.  
    36. Public Declare Function WSACleanup Lib "wsock32" () As Long
    37.  
    38. Public Declare Function gethostname Lib "wsock32" _
    39.   (ByVal szHost As String, _
    40.    ByVal dwHostLen As Long) As Long
    41.  
    42. Public Declare Function gethostbyname Lib "wsock32" _
    43.   (ByVal szHost As String) As Long
    44.  
    45. Public Declare Sub CopyMemory Lib "kernel32" _
    46.    Alias "RtlMoveMemory" _
    47.   (hpvDest As Any, _
    48.    ByVal hpvSource As Long, _
    49.    ByVal cbCopy As Long)
    50.  
    51.  
    52. Public Function GetIPAddress() As String
    53.  
    54.    Dim sHostName    As String * 256
    55.    Dim lpHost    As Long
    56.    Dim HOST      As HOSTENT
    57.    Dim dwIPAddr  As Long
    58.    Dim tmpIPAddr() As Byte
    59.    Dim i         As Integer
    60.    Dim sIPAddr  As String
    61.  
    62.    If Not SocketsInitialize() Then
    63.       GetIPAddress = ""
    64.       Exit Function
    65.    End If
    66.  
    67.   'gethostname returns the name of the local host into
    68.   'the buffer specified by the name parameter. The host
    69.   'name is returned as a null-terminated string. The
    70.   'form of the host name is dependent on the Windows
    71.   'Sockets provider - it can be a simple host name, or
    72.   'it can be a fully qualified domain name. However, it
    73.   'is guaranteed that the name returned will be successfully
    74.   'parsed by gethostbyname and WSAAsyncGetHostByName.
    75.  
    76.   'In actual application, if no local host name has been
    77.   'configured, gethostname must succeed and return a token
    78.   'host name that gethostbyname or WSAAsyncGetHostByName
    79.   'can resolve.
    80.    If gethostname(sHostName, 256) = SOCKET_ERROR Then
    81.       GetIPAddress = ""
    82.       MsgBox "Windows Sockets error " & Str(WSAGetLastError()) & _
    83.               " has occurred. Unable to successfully get Host Name."
    84.       SocketsCleanup
    85.       Exit Function
    86.    End If
    87.  
    88.   'gethostbyname returns a pointer to a HOSTENT structure
    89.   '- a structure allocated by Windows Sockets. The HOSTENT
    90.   'structure contains the results of a successful search
    91.   'for the host specified in the name parameter.
    92.  
    93.   'The application must never attempt to modify this
    94.   'structure or to free any of its components. Furthermore,
    95.   'only one copy of this structure is allocated per thread,
    96.   'so the application should copy any information it needs
    97.   'before issuing any other Windows Sockets function calls.
    98.  
    99.   'gethostbyname function cannot resolve IP address strings
    100.   'passed to it. Such a request is treated exactly as if an
    101.   'unknown host name were passed. Use inet_addr to convert
    102.   'an IP address string the string to an actual IP address,
    103.   'then use another function, gethostbyaddr, to obtain the
    104.   'contents of the HOSTENT structure.
    105.    sHostName = Trim$(sHostName)
    106.    lpHost = gethostbyname(sHostName)
    107.  
    108.    If lpHost = 0 Then
    109.       GetIPAddress = ""
    110.       MsgBox "Windows Sockets are not responding. " & _
    111.               "Unable to successfully get Host Name."
    112.       SocketsCleanup
    113.       Exit Function
    114.    End If
    115.  
    116.   'to extract the returned IP address, we have to copy
    117.   'the HOST structure and its members
    118.    CopyMemory HOST, lpHost, Len(HOST)
    119.    CopyMemory dwIPAddr, HOST.hAddrList, 4
    120.  
    121.   'create an array to hold the result
    122.    ReDim tmpIPAddr(1 To HOST.hLen)
    123.    CopyMemory tmpIPAddr(1), dwIPAddr, HOST.hLen
    124.  
    125.   'and with the array, build the actual address,
    126.   'appending a period between members
    127.    For i = 1 To HOST.hLen
    128.       sIPAddr = sIPAddr & tmpIPAddr(i) & "."
    129.    Next
    130.  
    131.   'the routine adds a period to the end of the
    132.   'string, so remove it here
    133.    GetIPAddress = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)
    134.  
    135.    SocketsCleanup
    136.  
    137. End Function
    138.  
    139.  
    140. Public Function GetIPHostName() As String
    141.  
    142.     Dim sHostName As String * 256
    143.  
    144.     If Not SocketsInitialize() Then
    145.         GetIPHostName = ""
    146.         Exit Function
    147.     End If
    148.  
    149.     If gethostname(sHostName, 256) = SOCKET_ERROR Then
    150.         GetIPHostName = ""
    151.         MsgBox "Windows Sockets error " & Str(WSAGetLastError()) & _
    152.                 " has occurred.  Unable to successfully get Host Name."
    153.         SocketsCleanup
    154.         Exit Function
    155.     End If
    156.  
    157.     GetIPHostName = Left$(sHostName, InStr(sHostName, Chr(0)) - 1)
    158.     SocketsCleanup
    159.  
    160. End Function
    161.  
    162.  
    163. Public Function HiByte(ByVal wParam As Integer) As Byte
    164.  
    165.   'note: VB4-32 users should declare this function As Integer
    166.    HiByte = (wParam And &HFF00&) \ (&H100)
    167.  
    168. End Function
    169.  
    170.  
    171. Public Function LoByte(ByVal wParam As Integer) As Byte
    172.  
    173.   'note: VB4-32 users should declare this function As Integer
    174.    LoByte = wParam And &HFF&
    175.  
    176. End Function
    177.  
    178.  
    179. Public Sub SocketsCleanup()
    180.  
    181.     If WSACleanup() <> ERROR_SUCCESS Then
    182.         MsgBox "Socket error occurred in Cleanup."
    183.     End If
    184.  
    185. End Sub
    186.  
    187. Public Function SocketsInitialize() As Boolean
    188.  
    189.    Dim WSAD As WSADATA
    190.    Dim sLoByte As String
    191.    Dim sHiByte As String
    192.  
    193.    If WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS Then
    194.       MsgBox "The 32-bit Windows Socket is not responding."
    195.       SocketsInitialize = False
    196.       Exit Function
    197.    End If
    198.  
    199.  
    200.    If WSAD.wMaxSockets < MIN_SOCKETS_REQD Then
    201.         MsgBox "This application requires a minimum of " & _
    202.                 CStr(MIN_SOCKETS_REQD) & " supported sockets."
    203.  
    204.         SocketsInitialize = False
    205.         Exit Function
    206.     End If
    207.  
    208.  
    209.    If LoByte(WSAD.wVersion) < WS_VERSION_MAJOR Or _
    210.      (LoByte(WSAD.wVersion) = WS_VERSION_MAJOR And _
    211.       HiByte(WSAD.wVersion) < WS_VERSION_MINOR) Then
    212.  
    213.       sHiByte = CStr(HiByte(WSAD.wVersion))
    214.       sLoByte = CStr(LoByte(WSAD.wVersion))
    215.  
    216.       MsgBox "Sockets version " & sLoByte & "." & sHiByte & _
    217.              " is not supported by 32-bit Windows Sockets."
    218.  
    219.       SocketsInitialize = False
    220.       Exit Function
    221.  
    222.    End If
    223.  
    224.  
    225.   'must be OK, so lets do it
    226.    SocketsInitialize = True
    227.  
    228. End Function

    My attempt at a thought provoking sig.
    * Remove ALL assumptions. You'll probably find your problem.
    * New to the forums? READ THIS! The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft
    * Learn how to fish!
    * Subscribing to every thread I post in is like having a book mark in my mind. Every now and then I get to review a fond memory.
    * If you find my post helpful do me a 15 second favor and RATE it. (Rate Post. Over there <----)
    * Please mark all resolved threads as such. It makes searching for fixes SO much easier!
    * Have fun. We aren't on this rock for long, enjoy it.
    * Sometimes I'm wrong. When I am I admit it. Never am I malicious. If reading my post and you think otherwise, then it MAY be tongue in cheek. Read it again.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Finding the IP address of a machine.

    Quote Originally Posted by Darren M. View Post
    That being the situation I might suggest the following, knowing the IP could change and it sounds like you want proof that a specific machine clicked ok. (e.g. IP addresses can/will probably change. DHCP and all...)

    Assuming the machine name would suffice you could easily use something like this.....
    vb Code:
    1. Private Sub Command1_Click()
    2.     Dim strMachineName  As String
    3.     strMachineName = Environ$("COMPUTERNAME")
    4.     ' Send your message here
    5. End Sub
    This may not suffice because more than one machine may have the same Computername. Anyway thanks for the suggestion. I can use it for some other purpose.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Finding the IP address of a machine.

    Quote Originally Posted by Darren M. View Post
    I knew I had this code some where. I do not recall where I picked this up, I am not the author.

    So, just in case you MUST have the IP address.....
    vb Code:
    1. Option Explicit
    2.  
    3. Public Const MAX_WSADescription As Long = 256
    4. Public Const MAX_WSASYSStatus As Long = 128
    5. Public Const ERROR_SUCCESS       As Long = 0
    6. Public Const WS_VERSION_REQD     As Long = &H101
    7. Public Const WS_VERSION_MAJOR    As Long = WS_VERSION_REQD \ &H100 And &HFF&
    8. Public Const WS_VERSION_MINOR    As Long = WS_VERSION_REQD And &HFF&
    9. Public Const MIN_SOCKETS_REQD    As Long = 1
    10. Public Const SOCKET_ERROR        As Long = -1
    11.  
    12. Public Type HOSTENT
    13.    hName      As Long
    14.    hAliases   As Long
    15.    hAddrType  As Integer
    16.    hLen       As Integer
    17.    hAddrList  As Long
    18. End Type
    19.  
    20. Public Type WSADATA
    21.    wVersion      As Integer
    22.    wHighVersion  As Integer
    23.    szDescription(0 To MAX_WSADescription)   As Byte
    24.    szSystemStatus(0 To MAX_WSASYSStatus)    As Byte
    25.    wMaxSockets   As Integer
    26.    wMaxUDPDG     As Integer
    27.    dwVendorInfo  As Long
    28. End Type
    29.  
    30. Public Declare Function WSAGetLastError Lib "wsock32" () As Long
    31.  
    32. Public Declare Function WSAStartup Lib "wsock32" _
    33.   (ByVal wVersionRequired As Long, _
    34.    lpWSADATA As WSADATA) As Long
    35.  
    36. Public Declare Function WSACleanup Lib "wsock32" () As Long
    37.  
    38. Public Declare Function gethostname Lib "wsock32" _
    39.   (ByVal szHost As String, _
    40.    ByVal dwHostLen As Long) As Long
    41.  
    42. Public Declare Function gethostbyname Lib "wsock32" _
    43.   (ByVal szHost As String) As Long
    44.  
    45. Public Declare Sub CopyMemory Lib "kernel32" _
    46.    Alias "RtlMoveMemory" _
    47.   (hpvDest As Any, _
    48.    ByVal hpvSource As Long, _
    49.    ByVal cbCopy As Long)
    50.  
    51.  
    52. Public Function GetIPAddress() As String
    53.  
    54.    Dim sHostName    As String * 256
    55.    Dim lpHost    As Long
    56.    Dim HOST      As HOSTENT
    57.    Dim dwIPAddr  As Long
    58.    Dim tmpIPAddr() As Byte
    59.    Dim i         As Integer
    60.    Dim sIPAddr  As String
    61.  
    62.    If Not SocketsInitialize() Then
    63.       GetIPAddress = ""
    64.       Exit Function
    65.    End If
    66.  
    67.   'gethostname returns the name of the local host into
    68.   'the buffer specified by the name parameter. The host
    69.   'name is returned as a null-terminated string. The
    70.   'form of the host name is dependent on the Windows
    71.   'Sockets provider - it can be a simple host name, or
    72.   'it can be a fully qualified domain name. However, it
    73.   'is guaranteed that the name returned will be successfully
    74.   'parsed by gethostbyname and WSAAsyncGetHostByName.
    75.  
    76.   'In actual application, if no local host name has been
    77.   'configured, gethostname must succeed and return a token
    78.   'host name that gethostbyname or WSAAsyncGetHostByName
    79.   'can resolve.
    80.    If gethostname(sHostName, 256) = SOCKET_ERROR Then
    81.       GetIPAddress = ""
    82.       MsgBox "Windows Sockets error " & Str(WSAGetLastError()) & _
    83.               " has occurred. Unable to successfully get Host Name."
    84.       SocketsCleanup
    85.       Exit Function
    86.    End If
    87.  
    88.   'gethostbyname returns a pointer to a HOSTENT structure
    89.   '- a structure allocated by Windows Sockets. The HOSTENT
    90.   'structure contains the results of a successful search
    91.   'for the host specified in the name parameter.
    92.  
    93.   'The application must never attempt to modify this
    94.   'structure or to free any of its components. Furthermore,
    95.   'only one copy of this structure is allocated per thread,
    96.   'so the application should copy any information it needs
    97.   'before issuing any other Windows Sockets function calls.
    98.  
    99.   'gethostbyname function cannot resolve IP address strings
    100.   'passed to it. Such a request is treated exactly as if an
    101.   'unknown host name were passed. Use inet_addr to convert
    102.   'an IP address string the string to an actual IP address,
    103.   'then use another function, gethostbyaddr, to obtain the
    104.   'contents of the HOSTENT structure.
    105.    sHostName = Trim$(sHostName)
    106.    lpHost = gethostbyname(sHostName)
    107.  
    108.    If lpHost = 0 Then
    109.       GetIPAddress = ""
    110.       MsgBox "Windows Sockets are not responding. " & _
    111.               "Unable to successfully get Host Name."
    112.       SocketsCleanup
    113.       Exit Function
    114.    End If
    115.  
    116.   'to extract the returned IP address, we have to copy
    117.   'the HOST structure and its members
    118.    CopyMemory HOST, lpHost, Len(HOST)
    119.    CopyMemory dwIPAddr, HOST.hAddrList, 4
    120.  
    121.   'create an array to hold the result
    122.    ReDim tmpIPAddr(1 To HOST.hLen)
    123.    CopyMemory tmpIPAddr(1), dwIPAddr, HOST.hLen
    124.  
    125.   'and with the array, build the actual address,
    126.   'appending a period between members
    127.    For i = 1 To HOST.hLen
    128.       sIPAddr = sIPAddr & tmpIPAddr(i) & "."
    129.    Next
    130.  
    131.   'the routine adds a period to the end of the
    132.   'string, so remove it here
    133.    GetIPAddress = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)
    134.  
    135.    SocketsCleanup
    136.  
    137. End Function
    138.  
    139.  
    140. Public Function GetIPHostName() As String
    141.  
    142.     Dim sHostName As String * 256
    143.  
    144.     If Not SocketsInitialize() Then
    145.         GetIPHostName = ""
    146.         Exit Function
    147.     End If
    148.  
    149.     If gethostname(sHostName, 256) = SOCKET_ERROR Then
    150.         GetIPHostName = ""
    151.         MsgBox "Windows Sockets error " & Str(WSAGetLastError()) & _
    152.                 " has occurred.  Unable to successfully get Host Name."
    153.         SocketsCleanup
    154.         Exit Function
    155.     End If
    156.  
    157.     GetIPHostName = Left$(sHostName, InStr(sHostName, Chr(0)) - 1)
    158.     SocketsCleanup
    159.  
    160. End Function
    161.  
    162.  
    163. Public Function HiByte(ByVal wParam As Integer) As Byte
    164.  
    165.   'note: VB4-32 users should declare this function As Integer
    166.    HiByte = (wParam And &HFF00&) \ (&H100)
    167.  
    168. End Function
    169.  
    170.  
    171. Public Function LoByte(ByVal wParam As Integer) As Byte
    172.  
    173.   'note: VB4-32 users should declare this function As Integer
    174.    LoByte = wParam And &HFF&
    175.  
    176. End Function
    177.  
    178.  
    179. Public Sub SocketsCleanup()
    180.  
    181.     If WSACleanup() <> ERROR_SUCCESS Then
    182.         MsgBox "Socket error occurred in Cleanup."
    183.     End If
    184.  
    185. End Sub
    186.  
    187. Public Function SocketsInitialize() As Boolean
    188.  
    189.    Dim WSAD As WSADATA
    190.    Dim sLoByte As String
    191.    Dim sHiByte As String
    192.  
    193.    If WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS Then
    194.       MsgBox "The 32-bit Windows Socket is not responding."
    195.       SocketsInitialize = False
    196.       Exit Function
    197.    End If
    198.  
    199.  
    200.    If WSAD.wMaxSockets < MIN_SOCKETS_REQD Then
    201.         MsgBox "This application requires a minimum of " & _
    202.                 CStr(MIN_SOCKETS_REQD) & " supported sockets."
    203.  
    204.         SocketsInitialize = False
    205.         Exit Function
    206.     End If
    207.  
    208.  
    209.    If LoByte(WSAD.wVersion) < WS_VERSION_MAJOR Or _
    210.      (LoByte(WSAD.wVersion) = WS_VERSION_MAJOR And _
    211.       HiByte(WSAD.wVersion) < WS_VERSION_MINOR) Then
    212.  
    213.       sHiByte = CStr(HiByte(WSAD.wVersion))
    214.       sLoByte = CStr(LoByte(WSAD.wVersion))
    215.  
    216.       MsgBox "Sockets version " & sLoByte & "." & sHiByte & _
    217.              " is not supported by 32-bit Windows Sockets."
    218.  
    219.       SocketsInitialize = False
    220.       Exit Function
    221.  
    222.    End If
    223.  
    224.  
    225.   'must be OK, so lets do it
    226.    SocketsInitialize = True
    227.  
    228. End Function

    I will try this out and inform. Thanks a lot.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Finding the IP address of a machine.

    Quote Originally Posted by dilettante View Post
    Well then did the simple Winsock control approach resolve the question?

    If so you can mark this revolved via the Thread Tools menu above.
    The method works. I have tried it on a Win XP machine.

    But since it requires the winsock control, I would like to know whether it will work on a Win 7 machine. If not how can I make it work?

  13. #13
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Finding the IP address of a machine.

    Quote Originally Posted by svg3414 View Post
    The method works. I have tried it on a Win XP machine.

    But since it requires the winsock control, I would like to know whether it will work on a Win 7 machine. If not how can I make it work?
    I forgot to mention I was using Windows 7 when I posted the posts above. So, yes, that code does work in Windows 7.

    Edit:

    That is I tested the code before posting it.
    Last edited by Nightwalker83; Apr 6th, 2012 at 01:44 AM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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