IE Proxy Switcher Deskband
-
I am currently developing a little IE deskband that gives the user the ability to hotswap between proxy settings with the click of a button, the button then changes to the user knows what the current proxy setting is(Green Means Proxy On|Red Means Proxy off). The one problem I am running into is the fact that it is able to determine the proxy setting when I start IE and thus the button is correctly set, but if I manually change the proxy through IE via Tools -> Internet Options -> Connection Tab -> Lan Settings, the button doesn't update. I was wondering if there is anyway I could envoke a ilstener that would be able to notice when I manaully change the proxy and then set the button based on its current setting after said event. Might be a difficult explanation to understand but if anybody is interested please e-mail me if you want further explanation.
-
I am currently developing a little IE deskband that gives the user the ability to hotswap between proxy settings with the click of a button, the button then changes to the user knows what the current proxy setting is(Green Means Proxy On|Red Means Proxy off). The one problem I am running into is the fact that it is able to determine the proxy setting when I start IE and thus the button is correctly set, but if I manually change the proxy through IE via Tools -> Internet Options -> Connection Tab -> Lan Settings, the button doesn't update. I was wondering if there is anyway I could envoke a ilstener that would be able to notice when I manaully change the proxy and then set the button based on its current setting after said event. Might be a difficult explanation to understand but if anybody is interested please e-mail me if you want further explanation.
Use RegNotifyChangeKeyValue() to watch this registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings http://msdn.microsoft.com/library/en-us/sysinfo/base/regnotifychangekeyvalue.asp?frame=true[^]
-
Use RegNotifyChangeKeyValue() to watch this registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings http://msdn.microsoft.com/library/en-us/sysinfo/base/regnotifychangekeyvalue.asp?frame=true[^]
Thanks for pointing me in the right direction Gerald. but I can't quite seem to figure out how to exactly write something that would actively monitor for a change in this registry key. Any help with this would be greatly appreciated. I'm not an expert developer so you'll have to bear with me.
-
Thanks for pointing me in the right direction Gerald. but I can't quite seem to figure out how to exactly write something that would actively monitor for a change in this registry key. Any help with this would be greatly appreciated. I'm not an expert developer so you'll have to bear with me.
RegNotifyChangeKeyValue monitors the registry key for you. If you use the RegNotifyChangeKeyValue synchronously, then it waits until a subkey has changed before continuing execution. You could use a loop and continue to moniter. If you use RegNotifyChangeKeyValue asynchronously, then you wait on the event instead. Run the code below. It will wait during the call to RegNotifyChangeKeyValue. Then change your proxy setting through IE and click ok. Then you will see the MessageBox.
#include <tchar.h>
#include <windows.h>INT WINAPI
_tWinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
INT nCmdShow
)
{
LONG l = 0L;
HKEY hKey = {0};l = RegOpenKeyEx ( HKEY\_CURRENT\_USER, \_T("Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Internet Settings"), 0, KEY\_NOTIFY, &hKey ); if(l == ERROR\_SUCCESS) { // The following call will wait until a change is made to the registry key. l = RegNotifyChangeKeyValue ( hKey, FALSE, REG\_NOTIFY\_CHANGE\_LAST\_SET, NULL, FALSE ); MessageBox(NULL, \_T("Registry key changed"), \_T("Registry key changed"), 0); RegCloseKey(hKey); } return 0;
}