Unable to query proxy “Automatically Detect Settings” on windows 7

故事扮演 提交于 2019-11-30 23:57:18

This is a new performance-optimizing feature introduced in IE8 called SmartWPAD.

WinINET keeps track of whether a given network has a WPAD server (e.g. what the Automatically Detect feature is used to look for). If the network does not have a WPAD server, then WinINET effectively "masks out" the "Use autodetect" bit when you do the InternetQueryOption so that your code doesn't waste a ton of time doing a proxy lookup that will return no proxy on this network.

If you MUST get the UI state (defeating the WinINET SWPAD feature) because, for instance, you plan to take this information and cache it for use on some other network, or something similar, then you must query for INTERNET_PER_CONN_FLAGS_UI first-- when you use this option, you will get back the UI state, independent of the SWPAD feature.

If this query fails, then the system is running a previous version of Internet Explorer and the client should query again with INTERNET_PER_CONN_FLAGS.

I have a C# code snippet where you can Check/Uncheck 'Automatically detect settings' check box of IE Connection Settings. You can find what you are looking for in this snippet.

    public bool IsIEAutoDetectProxy(bool set)
    {
        // Setting Proxy information for IE Settings.
        RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections", true);
        byte[] defConnection = (byte[])RegKey.GetValue("DefaultConnectionSettings");
        if (defConnection[8] == Convert.ToByte(9))
           return true;
        else
           return false;
    } 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!