C# 禁用代理

C# 禁用代理,c#,proxy,C#,Proxy,我使用此函数设置webbrowser控件的代理 private void SetProxy(string proxy) { INTERNET_PROXY_INFO IPI = new INTERNET_PROXY_INFO(); IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY; IPI.lpszProxy = System.Runtime.InteropServices.Marshal.St

我使用此函数设置webbrowser控件的代理

    private void SetProxy(string proxy)
    {
        INTERNET_PROXY_INFO IPI = new INTERNET_PROXY_INFO();

        IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
        IPI.lpszProxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(proxy);
        IPI.lpszProxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("local");

        IntPtr intptrStruct = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(IPI));


        System.Runtime.InteropServices.Marshal.StructureToPtr(IPI, intptrStruct, true);
        InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(IPI));
    }
但我无法禁用/删除该代理,只能将其替换为另一个代理。如何完全删除代理。 已由注册表尝试

没有普通链接作为答案。

请尝试设置


IPI.dwAccessType to

当您想使用代理时,为什么不只使用一个webproxy,而当您想使用一个没有web代理的连接时,只需在没有代理的情况下创建它?我不是在webrequest上使用它,我是在webbrowser控件上使用它。只是想知道,您知道一种快速方法来知道代理是否启动,因为我必须在控件生效前刷新两次。无论如何,谢谢你,让它休眠5秒