Old 12th August 2003, 04:53   #1
dajvid
Junior Member
 
Join Date: May 2003
Location: Perth, Western Australia
Posts: 22
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.
dajvid is offline   Reply With Quote
Old 12th August 2003, 13:11   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th August 2003, 03:59   #3
dajvid
Junior Member
 
Join Date: May 2003
Location: Perth, Western Australia
Posts: 22
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.
dajvid is offline   Reply With Quote
Old 13th August 2003, 11:58   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 14th August 2003, 03:18   #5
dajvid
Junior Member
 
Join Date: May 2003
Location: Perth, Western Australia
Posts: 22
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.

Quote:
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.

code:

!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.
dajvid is offline   Reply With Quote
Old 14th August 2003, 11:46   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
This is taken from MSDN:

Quote:
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 15th August 2003, 03:53   #7
dajvid
Junior Member
 
Join Date: May 2003
Location: Perth, Western Australia
Posts: 22
Thanks Kichik, it works an absolute treat! Here's the final code for any future readers:

code:

!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.
dajvid is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump