I am trying to capture proxy setting (\"Automatically Detect Settings\"). My code works on XP and Vista. But it is NOT working on Windows 7
Please see the details of
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;
}