Archive: Refreshing the program groups in the Start Menu


Refreshing the program groups in the Start Menu
Hi,

My installer needs to migrate an existing installation that created Start Menu shortcuts in the current user profile to recreating those Start Menu shortcuts in the all users profile. While I'm able to delete the shortcuts and program group in the current user profile and recreate them in the all users profile, Windows XP (this may also affect Windows 2000) does not refresh the Start Menu accordingly.

Windows XP (I don't have a Windows 2000 box to test this on) combines the Start Menu of the current user and all users profiles into one list. After deleting all the shortcuts and the program group from the current user profile, I recreate the shortcuts in a program group of the exact same name in the all user profile. Windows XP gets confused and ends up displaying an empty program group in the Start Menu, even though the shortcuts exist in the all users profile. The only way I've found to get Windows XP to refresh this is to get a user to either logout/login or reboot.

Is there any way to get NSIS to refresh the Start Menu without rebooting the computer?

Many thanks,
Dave.


A notification of some kind using SHChangeNotify should probably help XP refresh its data. Have a look at this page for an example usage:

http://nsis.sourceforge.net/archive/...php?pageid=202

If I had to take a guess I'd say SHCNE_DELETE would do the trick.


Using the SHChangeNotify example above, I've tried substituting SHCNE_DELETE, SHCNE_RMDIR and even SHCNE_ALLEVENTS, without success.

I'm fumbling a little in the dark because I do not quite understand the uFlags parameter. SHCNF_IDLIST refers to the Desktop folder, however I do not know whether this encompasses the virtual Desktop folder, that would cover all folders including both current and all users Start Menus, or whether it is the physical Desktop folder, located in the %PROFILE%\Desktop, which would not include the current and all users Start Menus. I am also uncertain how to use the other uFlags options.

Ta,
Dave.


Have you defined all of the values correctly? Why use SHCNF_IDLIST with the desktop when you can use SHCNF_PATH with a real path?


My best guess for the correct parameters is to use SHCNE_RMDIR to reflect deleting the program group in the current user profile and to use SHCNF_PATH to specify the current user start menu, although I do not know how to pass the path to the system call.

SHCNF_PATH
dwItem1 and dwItem2 are the addresses of null-terminated strings of maximum length MAX_PATH that contain the full path names of the items affected by the change.
I don't know how to specify the path and why I'd need to specify two strings. I'm not even sure whether SHCNF_PATH is 0x01 or 0x05.

This is what I have right now, althought this won't work.


!define SHCNE_RMDIR 0x010
!define SHCNF_PATH 0x01

Function RefreshStartMenu
; Based on RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(l, l, i, i) v \
(${SHCNE_RMDIR}, ${SHCNF_PATH}, 0, 0)'
FunctionEnd

Any code would be greatly appreciated.

Ta,
Dave.

This is taken from MSDN:

A folder has been created. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that was created. dwItem2 is not used and should be NULL.
It means dwItem1 must contain a pointer to a string specifying the path. SHCNF_PATH must be 0x1 because this string is ASCII and not Wide. The code should look like this:

System::Call 'shell32.dll::SHChangeNotify(i ${SHCNE_RMDIR}, i ${SHCNF_PATH}, t "$SMPROGRAMS\my program", i 0)'

BTW, there was an error in the script on the archive. Instead of i in the first two parms it used l which means System.dll should send int64.

Thanks Kichik, it works an absolute treat! Here's the final code for any future readers:


!define SHCNE_RMDIR 0x010
!define SHCNF_PATH 0x01

Function NotifyRmDir
; Based on RefreshShellIcons By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, t, i) v \
(${SHCNE_RMDIR}, ${SHCNF_PATH}, "directory to notify", 0)'
FunctionEnd


Ta,
Dave.