views:

78

answers:

1

I am wondering is there a way to refresh the HKLM registry key HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer - without restarting the shell.

I would like to be able to do this without restarting explorer. Is there any known way to do that ?

So far, I found only this thing:

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True

which doesn't work for my case.

It looks insane to me that MS made Explorer so it can't re-read its configuration while running) but you never know.

EDIT: What I try to do is to disable/enable notification area (tray) without restarting. The registry key is

Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\

Variable: NoTrayItemsDisplay

Value: 1/0

EDIT 2 This is the source code that supposed to work, but on Vista it doesn't, not for notification area, not for my testing dummy which was MyMusic in startMenu (variable NoStartMenuMyMusic)

#include <stdio.h>
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
   DWORD dwRetVal;

  int  lResult = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)0,
                      (LPARAM)"Policy",
                      SMTO_ABORTIFHUNG, 5000, &dwRetVal);

   printf("lResult  = %ld\n", lResult);
   printf("dwRetVal = %ld\n", dwRetVal);

   return 0;
}

I tried all sane wparam and lparam values without success. I took the code from here and dude claims it works...

This article, however, claims that code doesn't work.

Whats even more ridiculous is that gpupdate is suposed to do the job.

Thx.

+1  A: 

Try sending the WM_SETTINGCHANGE message with wparam=0 and lparam="Policy" to the taskbar, not sure if this can be done with scripting

Anders
It doesn't work. I used SendMessageTimeout to send the message and it returns 1 as a result which means it passed OK. However, nothing happens.
majkinetor
you could try wparam=1 also, check the link, that is how it is supposed to work
Anders
No its not. Applications must send NULL, system sends 1. Anyway, I edited the post and gave C code. Perhaps you can try it yourself.
majkinetor
Well, you want to emulate the system, so you can't use NULL. If it does not work, it probably means explorer only updates that value on startup
Anders