Results 1 to 8 of 8

Thread: IP Address

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    Question IP Address

    I have lots of salesmen that go all over the place and use 1001 different ISPs. I need to write a program that checks their IP and modifies their settings on the fly. How can I change the IP address of certain adapters? I searched the forums and looked through the registry and nothing comes up in either. Any ideas?

    Thanks!

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    jsun9

    What you need is a Client/Server approach. You need to have a program running on each saleman's pc that will respond to a command you send it while online and do what is neccessary.

    What do you mean change the IP Address of certain adapters?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525
    The client server approach would not work since they can't get to the internet in the first place.

    Many salesman have multiple adapters like dial up, vpn and local area connection, etc. I need to make sure i'm changing the local area connection and not dial up, etc..

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Why would you need to change their IPs?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    jsun9

    Each pc can have multiple adapters. You probably want to find the active one and get that IP. You can get the Active IP by using the Winsock control. You could aslo try this from the API-Guide:

    VB Code:
    1. 'This project requires the following components:
    2. ' - a form (Form1) with a textbox (Text1, Multiline=True)
    3. '   and a command button (Command1)
    4. ' - a module (Module1)
    5.  
    6. 'in Form1:
    7. Private Sub Command1_Click()
    8.     Module1.Start
    9. End Sub
    10.  
    11. 'In Module1:
    12.  
    13. '******************************************************************
    14. 'Created By Verburgh Peter.
    15. ' 07-23-2001
    16. ' [email][email protected][/email]
    17. '-------------------------------------
    18. 'With this small application , you can detect the IP's installed on your computer,
    19. 'including subnet mask , BroadcastAddr..
    20. '
    21. 'I've wrote this because i've a programm that uses the winsock control, but,
    22. 'if you have multiple ip's  installed on your pc , you could get by using the Listen
    23. ' method the wrong ip ...
    24. 'Because Winsock.Localip => detects the default ip installed on your PC ,
    25. ' and in most of the cases it could be the LAN (nic) not the WAN (nic)
    26. 'So then you have to use the Bind function ,to bind to your right ip..
    27. 'but how do you know & find that ip ?
    28. 'you can find it now by this appl.. it check's in the api.. IP Table..
    29. '******************************************************************
    30.  
    31.  
    32. Const MAX_IP = 5   'To make a buffer... i dont think you have more than 5 ip on your pc..
    33.  
    34. Type IPINFO
    35.      dwAddr As Long   ' IP address
    36.     dwIndex As Long '  interface index
    37.     dwMask As Long ' subnet mask
    38.     dwBCastAddr As Long ' broadcast address
    39.     dwReasmSize  As Long ' assembly size
    40.     unused1 As Integer ' not currently used
    41.     unused2 As Integer '; not currently used
    42. End Type
    43.  
    44. Type MIB_IPADDRTABLE
    45.     dEntrys As Long   'number of entries in the table
    46.     mIPInfo(MAX_IP) As IPINFO  'array of IP address entries
    47. End Type
    48.  
    49. Type IP_Array
    50.     mBuffer As MIB_IPADDRTABLE
    51.     BufferLen As Long
    52. End Type
    53.  
    54. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    55. Public Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
    56. Sub main()
    57. Form1.Show
    58. End Sub
    59.  
    60. 'converts a Long  to a string
    61. Public Function ConvertAddressToString(longAddr As Long) As String
    62.     Dim myByte(3) As Byte
    63.     Dim Cnt As Long
    64.     CopyMemory myByte(0), longAddr, 4
    65.     For Cnt = 0 To 3
    66.         ConvertAddressToString = ConvertAddressToString + CStr(myByte(Cnt)) + "."
    67.     Next Cnt
    68.     ConvertAddressToString = Left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)
    69. End Function
    70.  
    71. Public Sub Start()
    72. Dim Ret As Long, Tel As Long
    73. Dim bBytes() As Byte
    74. Dim Listing As MIB_IPADDRTABLE
    75.  
    76. Form1.Text1 = ""
    77.  
    78. On Error GoTo END1
    79.     GetIpAddrTable ByVal 0&, Ret, True
    80.  
    81.     If Ret <= 0 Then Exit Sub
    82.     ReDim bBytes(0 To Ret - 1) As Byte
    83.     'retrieve the data
    84.     GetIpAddrTable bBytes(0), Ret, False
    85.      
    86.     'Get the first 4 bytes to get the entry's.. ip installed
    87.     CopyMemory Listing.dEntrys, bBytes(0), 4
    88.     'MsgBox "IP's found : " & Listing.dEntrys    => Founded ip installed on your PC..
    89.     Form1.Text1 = Listing.dEntrys & "   IP addresses found on your PC !!" & vbCrLf
    90.     Form1.Text1 = Form1.Text1 & "----------------------------------------" & vbCrLf
    91.     For Tel = 0 To Listing.dEntrys - 1
    92.         'Copy whole structure to Listing..
    93.        ' MsgBox bBytes(tel) & "."
    94.         CopyMemory Listing.mIPInfo(Tel), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len(Listing.mIPInfo(Tel))
    95.          Form1.Text1 = Form1.Text1 & "IP address                   : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr) & vbCrLf
    96.          Form1.Text1 = Form1.Text1 & "IP Subnetmask            : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwMask) & vbCrLf
    97.          Form1.Text1 = Form1.Text1 & "BroadCast IP address  : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwBCastAddr) & vbCrLf
    98.          Form1.Text1 = Form1.Text1 & "**************************************" & vbCrLf
    99.     Next
    100.  
    101. 'MsgBox ConvertAddressToString(Listing.mIPInfo(1).dwAddr)
    102. Exit Sub
    103. END1:
    104. MsgBox "ERROR"
    105. End Sub

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525
    thanks for the help randem.

    does anyone know how to actually modify the IPs?

  7. #7
    Hyperactive Member
    Join Date
    Jun 2003
    Location
    Manchester, CT
    Posts
    317
    We have something similar at my job, you might want to try an application called netswitcher

    http://www.netswitcher.com

    it works really well, as a matter of fact I use it for myself when I go to client sites

    Very easy to use and configure, and very simple for an end user who may not know everything about everything when it comes to networking
    "I dont even see the code anymore... I just see Blonde, Brunette, Redhead..."

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525
    that's pretty much exactly what I want to do.. but.. i still want to know how they do it. that program is still way to complicated for my salesmen.............

    anyone know how to do this?????

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