Partager via


Programatically setting Wininet/Internet Explorer's Proxy settings

We got a question in the comments:

I wonder how I can set the proxy server for WinInet
programmatically? Actually I want to be able to flip flop the proxy setting
(for IE) programmatically. Thanks Victor

There is two parts to doing this.

  1. Pass NULL as the handle to InternetSetOption using the
    INTERNET_OPTION_PER_CONNECTION_OPTION instead of the legacy INTERNET_OPTION_PROXY
    (See KB226473: How to programmatically query and set proxy settings under Internet Explorer
    for more on this step)
  2. Call InternetSetOption with INTERNET_OPTION_PROXY_SETTINGS_CHANGED with
    NULL Buffer and 0 BufferLength to let all the instances of WinInet know to
    update their proxy settings. You can also use
    INTERNET_OPTION_SETTINGS_CHANGED but it has side effects on any Keep Alive
    connections in your current process.

Good luck Victor and sorry for the late response.

Comments

  • Anonymous
    September 22, 2011
    INTERNET_OPTION_PROXY_SETTINGS_CHANGED  is not work under WIN7