4

I change the default system folder icon via registry key

Reg := TRegistry.Create; 
try 
  Reg.RootKey := HKEY_LOCAL_MACHINE;
  Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons', True);
  Reg.WriteString('3', 'C:\MyIcon.icl,0');
finally
  RegFile.Free;
end;

I can change registry values, but the problem is I need to restart the OS for it to take effect.

To fix it I tried:

SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);

and:

SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);

It works on WinXP but does not on Win7.

How can i fix it on Win7?

gustavogbc
  • 695
  • 11
  • 33
barbaris
  • 514
  • 8
  • 25
  • delete *IconCache.db* could avoid a reboot – az01 Sep 21 '12 at 22:26
  • i have tried delete IconCache.db. It doesnt work – barbaris Sep 22 '12 at 11:17
  • icl file is icon library – barbaris Sep 23 '12 at 07:50
  • I've tried to translate even the way how TortoiseSVN does its *force notifiation*, no success. It's described in the answer to [`this question`](http://stackoverflow.com/q/647316/960757). – TLama Sep 23 '12 at 08:53
  • 2
    Take a look [here](http://stackoverflow.com/questions/1757737/how-to-tell-windows-explorer-to-refresh-its-icons). specially the [sledgehammer approach](https://groups.google.com/forum/?fromgroups=#!topic/microsoft.public.platformsdk.shell/Q54P8XGPQ3c). very nasty... – kobik Sep 23 '12 at 09:13
  • @kobik, that's how [`TortoiseSVN`](http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/src/Utils/ShellUpdater.cpp) does it (login: guest; no pass). However, even that had no effect when I've tried. – TLama Sep 23 '12 at 09:58
  • Try this one. Do not delete the Iconcache.db using explorer and while explorer process running, it will recreate the old copy. Instead, 1. close all explorer instance (from taskman), 2. go to ...Appdata\local folder and delete iconcache.db, and 3.restart explorer. – Hendra Sep 23 '12 at 10:53
  • oops, I forgot something, in step 2, go to cmd prompt and delete the file – Hendra Sep 23 '12 at 11:02

1 Answers1

1

Try to "end task" the process "explorer.exe" from task manager,

and start it again (Run -> explorer.exe),

if by this process you can see the updated icons, try to do this programmatically, so that you don't have to do a restart.

Amarnath Balasubramanian
  • 9,300
  • 8
  • 34
  • 62
Aby
  • 1,916
  • 1
  • 12
  • 18