Advertisement
BaSs_HaXoR

How to get a PROXY IN VB Webbrowser

Oct 19th, 2014
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.74 KB | None | 0 0
  1. 'SOURCE: Rogue: http://thebot.net/threads/tut-proxy-support-in-vb-net-c.142717/
  2.  
  3. 'STEP 1
  4. 'This code is accessing the .dll to enable the use of proxies.
  5. 'Goes at the top of the class (anywhere really but lets be orginaized)
  6.  
  7.  Private Declare Auto Function InternetSetOption Lib "wininet.dll" (ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean
  8.  
  9. 'STEP 2
  10. 'Now we must create a structure so that the proxy only affects the webbrowser in your application. Not your actual webbrowser
  11. '(IE, Chrome, Firefox, etc.)
  12.  
  13.   Public Structure Struct_INTERNET_PROXY_INFO
  14.         Public dwAccessType As Integer
  15.         Public proxy As IntPtr
  16.         Public proxyBypass As IntPtr
  17.     End Structure
  18.  
  19. 'STEP 3
  20. 'Now that we have done that we can now create the sub to call and set the proxy.
  21.  
  22.  Sub RefreshIESettings(ByVal strProxy As String)
  23.         Const INTERNET_OPTION_PROXY As Integer = 38
  24.         Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
  25.         Dim s_IPI As Struct_INTERNET_PROXY_INFO
  26.         s_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
  27.         s_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
  28.         s_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("Global")
  29.         Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(s_IPI))
  30.         System.Runtime.InteropServices.Marshal.StructureToPtr(s_IPI, intptrStruct, True)
  31.         InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(s_IPI))
  32.     End Sub
  33.  
  34. 'Now to call the sub we just use 1 line of code:
  35.  
  36. RefreshIESettings("IP:PORT")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement