How to recover Windows Icon Cache without closing explorer.exe or restart Windows?

Task

I'm trying to customize a folder icon from my application, but due to the way Windows caches icons and thumbnails, I struggle to get the modified folder to update its new icon.

There are two ways in Windows that I know how to configure the folder icon, the easiest way is to right-click the folder from Windows Explorer, Properties, and then select the “Configure” tab and change its icon, this method does not work, although since it requires Manually change folder properties.

The second way I make from my program is to create a file desktop.iniand put it in a folder that requires changing the icon, the documentation desktop.inican be found here: http://hwiegman.home.xs4all.nl/desktopini.html and the article here: http: //helpdeskgeek.com/how-to/customize-folder-icons-desktop-ini/

As shown below, the folder icon in Windows is not updated, although you can see from the folder properties that the icon has changed, just Windows does not show the updated folder icon:

enter image description here

I am fully aware of Windows caching icons and thumbnails, I searched and read a few pages on how to supposedly rebuild the icon cache and thus make Windows display the recently changed icon, not cached, however I cannot get this to work from my application without restarting Windows or the Explorer.exe process, this must be done without interrupting Windows, although closing Explorer.exe or needing to restart is absolutely not an option.

It is interesting, however, that when you change the folder icon at a glance, as I described earlier, Windows somehow manages to clear and rebuild the icon cache, since the changed folder is quickly updated to show the new icon, however, I don’t see what Windows tricks do to achieve this.

Attempts

A few things I tried unsuccessfully (in a specific order):

  • : ie4uinit.exe -ClearIconCache
  • Lazarus: SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
  • IconCache.db AppData\Local
  • "Always show icons, never thumbnails" Explorer , : HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced, IconsOnly
  • , : HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics, Shell Icon Size
  • Delphi, Lazarus: http://www.aha-soft.com/faq/q18.htm
  • db : AppData\Local\Microsoft\Windows\Explorer, , , , ..
  • , .
  • Windows "", , .

.

Windows, , , explorer.exe Windows, .

, Windows Explorer? , Windows Explorer?

- Windows 10, , .

+4
1

, ; , . , SHChangeNotify.

LPCWSTR pszFolder = L"c:\\path\\to\\folder";
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, pszFolder, NULL);
+3

Source: https://habr.com/ru/post/1624345/


All Articles