Discussion:
Notify the Shell to update its cache
(too old to reply)
Gordon Pan
2010-04-22 00:20:01 UTC
Permalink
Raw Message
Hi all,
I would like to change label to a drive letter.
I find a guide in msdn:
'http://msdn.microsoft.com/en-us/library/aa969356.aspx'

The following example specifies label for the E: drive.
For Windows 2000:

‧HKEY_CLASSES_ROOT\Applications\Explorer.exe\Drives\E\DefaultLabel\(Default)
= MyDrive
....
Finally, call SHChangeNotify to notify the Shell to update its cache.

I modify the registry as above guide, it works for changing the label of the
drive letter. However, it can't update immediately.
I have to open another 'Explorer', then the new label will be updated.
I have tried following codes, but it seems no effect:
SHChangeNotify(SHCNE_ALLEVENTS, SHCNF_FLUSH, NULL,NULL);
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST + SHCNF_FLUSH, NULL,
NULL);

SendMessageTimeout(HWND_BROADCAST,WM_SETTINGCHANGE,NULL,NULL,SMTO_NORMAL,1000,&dwResult);

Does anyone know how to notify the Shell to update its cache?
Any suggestion is highly appreciated.

Thanks!
Best Regards,
Gordon
Uwe Sieber
2010-04-27 03:52:47 UTC
Permalink
Raw Message
Since XP this works for me:
SHChangeNotify(SHCNE_RENAMEITEM, SHCNF_PATH, "X:\\", NULL);

Under W2K it seems to be required to make the reg setting
before the drive letter gets assigned. Later the only way
to update DefaultLabel and Icon seems to be to press F5.
So far I have found no shell call to perform this F5 style
refresh.

Furthermore some of these SHChangeNotify call seems to
have no effect at all if called from a service.


Uwe
Post by Gordon Pan
Hi all,
I would like to change label to a drive letter.
'http://msdn.microsoft.com/en-us/library/aa969356.aspx'
The following example specifies label for the E: drive.
‧HKEY_CLASSES_ROOT\Applications\Explorer.exe\Drives\E\DefaultLabel\(Default)
= MyDrive
....
Finally, call SHChangeNotify to notify the Shell to update its cache.
I modify the registry as above guide, it works for changing the label of the
drive letter. However, it can't update immediately.
I have to open another 'Explorer', then the new label will be updated.
SHChangeNotify(SHCNE_ALLEVENTS, SHCNF_FLUSH, NULL,NULL);
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST + SHCNF_FLUSH, NULL,
NULL);
SendMessageTimeout(HWND_BROADCAST,WM_SETTINGCHANGE,NULL,NULL,SMTO_NORMAL,1000,&dwResult);
Does anyone know how to notify the Shell to update its cache?
Any suggestion is highly appreciated.
Thanks!
Best Regards,
Gordon
Loading...