Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'SOURCE: Rogue: http://thebot.net/threads/tut-proxy-support-in-vb-net-c.142717/
- 'STEP 1
- 'This code is accessing the .dll to enable the use of proxies.
- 'Goes at the top of the class (anywhere really but lets be orginaized)
- 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
- 'STEP 2
- 'Now we must create a structure so that the proxy only affects the webbrowser in your application. Not your actual webbrowser
- '(IE, Chrome, Firefox, etc.)
- Public Structure Struct_INTERNET_PROXY_INFO
- Public dwAccessType As Integer
- Public proxy As IntPtr
- Public proxyBypass As IntPtr
- End Structure
- 'STEP 3
- 'Now that we have done that we can now create the sub to call and set the proxy.
- Sub RefreshIESettings(ByVal strProxy As String)
- Const INTERNET_OPTION_PROXY As Integer = 38
- Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
- Dim s_IPI As Struct_INTERNET_PROXY_INFO
- s_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
- s_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
- s_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("Global")
- Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(s_IPI))
- System.Runtime.InteropServices.Marshal.StructureToPtr(s_IPI, intptrStruct, True)
- InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(s_IPI))
- End Sub
- 'Now to call the sub we just use 1 line of code:
- RefreshIESettings("IP:PORT")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement