Vb help needed with proxies

Discussion in 'Visual Basic .NET' started by awsomnick1, Dec 20, 2011.

  1. awsomnick1

    awsomnick1 BANNED BANNED

    Joined:
    Feb 8, 2010
    Messages:
    539
    Likes Received:
    155
    I am trying to get a webbrowser control to authenticate for proxies with username and password. I can get it to work fine without authentication, but for with authentication im stuck. Here is my current code:

    Code:
    #Region "Proxy Support"
        <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
    #End Region
    Any help would be Greatly Appreciated
     
  2. Renwo

    Renwo Junior Member

    Joined:
    Aug 15, 2011
    Messages:
    131
    Likes Received:
    17
    Have you figured out how to use private proxies? I'm also looking for a solution. Code for regular public proxies is easily found on google, but not private proxy support.