1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help me . how to Use a sock 5 with webBrowser control C#

Discussion in 'C, C++, C#' started by format888, Apr 4, 2014.

  1. format888

    format888 Newbie

    Joined:
    Apr 4, 2014
    Messages:
    1
    Likes Received:
    0
    hi every body .
    I need some help from someone who has already use the webBrowser control along with a sock 5


    I'm using the code attached to set the sock into the webBrowser control,but seems to work only once during the execution, when I call it again in the loop it just doesn't work, I can get t ounderstand why.
    Hope some one could help me with this...


    my code :

    [DllImport("wininet.dll")]
    static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
    public struct Struct_INTERNET_PROXY_INFO
    {


    public int dwAccessType;


    public IntPtr proxy;


    public IntPtr proxyBypass;
    }
    public void RefreshIESettings(string strProxy)
    {
    const int INTERNET_OPTION_PROXY = 38;
    const int INTERNET_OPEN_TYPE_PROXY = 3;
    Struct_INTERNET_PROXY_INFO s_IPI;
    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");
    IntPtr intptrStruct = 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));
    }
     
    Last edited: Apr 4, 2014