Make Windows refresh icon cache

风流意气都作罢 提交于 2019-11-30 09:56:05

SystemParametersInfo() has a parameter called SPI_SETICONS that "Reloads the system icons" according to MSDN. I have never tried to use SPI_SETICONS so I don't know if it works, if you wanted to test you would use something like

System::Call 'user32::SystemParametersInfo(i 0x0058,i0,i0,i2)i' ;SPI_SETICONS

If it turns out that this is not enough, you can bring out the big undocumented hammer:

  1. Read REG_SZ value named "Shell Icon Size" in HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics (If the value is not there, either abort or use GetSystemMetrics(SM_CXICON))
  2. Subtract 1 from the number you got from step one
  3. Write the modified entry back to the registry
  4. Call SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, 100000, NULL)
  5. Write the number you got from step one entry back to the registry
  6. Call SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, 100000, NULL)

Note that this could re-arrange the desktop icons even if "Auto Arrange" is off and possibly other things that might annoy the user!

You can just run the following command line:

c:\Windows\System32\ie4uinit.exe -ClearIconCache

That command line will delete your cache icons without need to restart explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!