Hi all... i know that a tut of this is already posted, but not like this...
HOW TO USE PROXY WITH A WEBBROWSER IN VB.NET?
Very simple:
FIRST
Add in the namespace (above the public class form1) this:
Quote:Import System.Runtime.InteropServices
SECOND
UNDER the public Class Form1 add this:
Quote:#region "Using Proxy"
<Runtime.InteropServices.DllImport("wininet.dll", SetLastError:=True)> _
Private Shared Function InternetSetOption(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean
End Function
Public Structure Struct_INTERNET_PROXY_INFO
Public DAType As Integer
Public PR As IntPtr
Public PRB As IntPtr
End Structure
Private Sub UseProxy(ByVal strProxy As String)
Const INTERNET_OPTION_PROXY As Integer = 38
Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
Dim struct_IPI As Struct_INTERNET_PROXY_INFO
struct_IPI.DAType = INTERNET_OPEN_TYPE_PROXY
struct_IPI.PR = Marshal.StringToHGlobalAnsi(strProxy)
struct_IPI.PRB = Marshal.StringToHGlobalAnsi("local")
Dim intptrStruct As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI))
Marshal.StructureToPtr(struct_IPI, intptrStruct, True)
Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
End Sub
#end region
OK, You have finished, this is the usage of this:
Add 2 TextBoxes: In the TextBox1 you must put the IP of the proxy, in the TextBox2 you must put the port. This is the code:
Quote:UseProxy(Textbox1.Text & ":" & Textbox2.Text)
I've made this code by other tutorials, now i've found this code in my folders and i've thought to share this with the comunity.
PLEASE, IF YOU ARE TRYING TO PUT ME -REP, TELL ME WHY BEFORE PLEASE!

