Jump to content

WebBrowser a proxy


Dotinho

Recommended Posts

Boas, tenho uma questão que acho que é compliado...

É assim, alguns sites tipo "fileshare" dao para usar proxyes, então fiz um programa que se actualiza com o site http://www.proxy4free.com/page1.html. Extrai a lista de proxyese vai mudando sozinho..

O problema é que o webbrowser nao tem nenhum opção para enfiar um proxy, alguem tem alguma sugestão?

cmps

Luis Lourenço

Link to comment
Share on other sites

já encontrei aqui http://vbdotnetforum.com/index.php?/topic/503-use-proxy-with-web-browser-control/

    <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 dwAccessType As Integer
                Public proxy As IntPtr
                Public proxyBypass As IntPtr
        End Structure

        Private Sub RefreshIESettings(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

                ' Filling in structure
                struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
                struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy)
                struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local")

                ' Allocating memory
                Dim intptrStruct As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI))

                ' Converting structure to IntPtr
                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

Não esqeucer de Importar Systems.Runtime.Interop

e usa-se

 RefreshIESettings("125.125.36.25:80")

Luis Lourenço

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.