Registry Notifier into a deskband?
-
Alright I got the following code from on here to be able to notify when a registry key has been modified. The only problem is, I can't figure out how to implement this code into the DLL that I'm creating that will be used in an IE deskband. The problem I'm running into is that if I make it sychronous it will noticebly hang in IE while it waits for the Reg Key to change. Any ideas wouldn't be helpful. #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; }
-
Alright I got the following code from on here to be able to notify when a registry key has been modified. The only problem is, I can't figure out how to implement this code into the DLL that I'm creating that will be used in an IE deskband. The problem I'm running into is that if I make it sychronous it will noticebly hang in IE while it waits for the Reg Key to change. Any ideas wouldn't be helpful. #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; }
try putting that bit of code in a seperate thread, using the CreateThread function. Call create thread from the entry point.
-
try putting that bit of code in a seperate thread, using the CreateThread function. Call create thread from the entry point.
So you are saying I should call create thread from where I load the DLL file? And this will in turn always be activated, thus responding everytime the said regirsty key is changed. I'm alittle new at programming C++, sorry. Appreciate the help.
-
So you are saying I should call create thread from where I load the DLL file? And this will in turn always be activated, thus responding everytime the said regirsty key is changed. I'm alittle new at programming C++, sorry. Appreciate the help.
yes thats exactly wot i mean. but don't create it in DllMain. create it in the function in your dll that is called. goto msdn.com and familiarise urself with creating thread, cos thats one of the things c++ does best, and is always useful.