[msdos] Proxy settings rehash/apply

Hi all,

I'm trying to enable/disable the usage of my proxy-server settings with this dos commands:

To turn on:
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f

To turn off:
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f

Those 2 commands works fine, because when I execute them and I check it in the settings at the control panel, they are set well.

But this is my problem:

When I enable/disable the proxy-server with one of this 2 commands, it only is beeing 'applied' when I go to the control panel -> internet options -> ..Proxy settings and press the 'OK' button (because settings are already set by DOS)

Is there a way to fix it that I don't have to go to the control panel anymore and that I can do it all the way by msdos commands? A kind of 'rehash' or 'apply'?

Greets,

~Oneday

PS: Of course I know it doesn't seem very usefull this way, but it's to include in a C++ program to easy switch proxy-settings on/off. I know this already exist but I would like to understand how to make this things on my own.
Last edited on
If this is going to be for a C\C++ app then let's do it right. Don't mix and match batch file commands with C or C++ just because "system(...)" allows you to, this is not only sloppy but it actually makes things more complicated then they need to be.

Here is the section of MSDN that you will want to look at:

- RegOpenKey(...) : http://msdn.microsoft.com/en-us/library/windows/desktop/ms724895(v=vs.85).aspx This will give you the handle to the registry key that you specify with a string.

- RegSetKeyValue(...) : http://msdn.microsoft.com/en-us/library/windows/desktop/ms724921(v=VS.85).aspx This will allow you to modify the key specified by the handle you grabbed with the "RegOpenKey(...)" function.

OTHER NOTES: You will need to include Winreg.h and you will have to link to the Advapi32.dll.
Maybe you need to also call SHChangeNotify() API to inform Explorer about the changes ...
Okay thanks both! :) I'll try it that way.
Topic archived. No new replies allowed.