Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to tell Windows Explorer to refresh its icons?
    primarykey
    data
    text
    <p>Once my installer finishes installing new versions of my application's exe, I'd like to tell Explorer to use the new exe's icons for its shortcuts. However, I cannot figure out how to do this.</p> <p>From reading online, it looks like the problem is that the <a href="http://www.catch22.net/tuts/sysimg" rel="nofollow noreferrer">system image list</a> is caching an old version of the icon. I tried calling <a href="http://msdn.microsoft.com/en-us/library/bb762118%28VS.85%29.aspx" rel="nofollow noreferrer">SHChangeNotify</a> with a <code>SHCNE_UPDATEIMAGE</code> parameter. I tried calling <a href="http://msdn.microsoft.com/en-us/library/bb762258%28VS.85%29.aspx" rel="nofollow noreferrer">SHUpdateImage</a>. I even tried the <a href="http://groups.google.com/group/microsoft.public.platformsdk.shell/browse_thread/thread/439e0ff1718f4377" rel="nofollow noreferrer">sledgehammer approach</a> of broadcasting <code>WM_SETTINGCHANGE</code>. Nothing seems to work.</p> <p>It's entirely possible that I'm just doing something wrong. Any help would be appreciated.</p> <p>Warning: Very ugly test code follows.</p> <pre><code>#if 1 // First attempt: using shell functions wchar_t icon_path[MAX_PATH]; int icon_index; UINT icon_flags; IShellFolder *desktop_folder; IShellFolder *sub_folder; IExtractIcon *extract_icon; LPITEMIDLIST pidl; SHGetDesktopFolder(&amp;desktop_folder); wchar_t *folder_path = L"C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\MyCompany\\"; desktop_folder-&gt;ParseDisplayName(NULL, NULL, folder_path, NULL, &amp;pidl, NULL); desktop_folder-&gt;BindToObject(pidl, NULL, IID_IShellFolder, (void**) &amp;sub_folder); sub_folder-&gt;ParseDisplayName(NULL, NULL, L"MyApp.lnk", NULL, &amp;pidl, NULL); sub_folder-&gt;GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*) &amp;pidl, IID_IExtractIcon, NULL, (void**) &amp;extract_icon); extract_icon-&gt;GetIconLocation(0, icon_path, MAX_PATH, &amp;icon_index, &amp;icon_flags); SHFILEINFO sfi; DWORD_PTR result = SHGetFileInfo(shortcut_path, 0, &amp;sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); SHUpdateImage(icon_path, icon_index, icon_flags, sfi.iIcon); // sfi.iIcon should be correct, but we'll try both, just for fun... SHChangeNotify(SHCNE_UPDATEIMAGE, SHCNF_DWORD, NULL, (LPCVOID) icon_index); SHChangeNotify(SHCNE_UPDATEIMAGE, SHCNF_DWORD, NULL, (LPCVOID) sfi.iIcon); #else // Second attempt: broadcasting a settings change HKEY reg; RegCreateKeyEx(HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics", 0, NULL, 0, KEY_SET_VALUE, NULL, &amp;reg, NULL); DWORD value; value = 33; RegSetValueEx(reg, L"Shell Icon Size", 0, REG_DWORD, (BYTE*) &amp;value, sizeof(value)); value = 32; SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, (int) L"WindowMetrics"); RegSetValueEx(reg, L"Shell Icon Size", 0, REG_DWORD, (BYTE*) &amp;value, sizeof(value)); SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, (int) L"WindowMetrics"); #endif </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload