开发者

C# disable proxy

开发者 https://www.devze.com 2023-03-03 10:12 出处:网络
I set my webbrowser control\'s proxy using this function private void SetProxy(string proxy) { INTERNET_PROXY_INFO IPI = new INTERNET_PROXY_INFO();

I set my webbrowser control's proxy using this function

    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(Sys开发者_如何学JAVAtem.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));
    }

But I am unable to disable/remove the proxy afterwards, only swap it for another proxy. How can I remove the proxy completely. Already tried by registry.

No plain links as answers.


Try setting

IPI.dwAccessType to INTERNET_OPEN_TYPE_DIRECT

0

精彩评论

暂无评论...
验证码 换一张
取 消