Some XE2 Programs Don't Show new executable Ic

2019-01-19 07:22发布

问题:

I have several programs written in Delphi XE2 that were converted from Delphi 2005, which under Windows 7 would display horribly scaled icons when shortcuts were made on the Desktop.

Using IcoFX, I created a new icon containing the usual 4 sizes (256, 48, 32, 16) and went through my programs, going to the Appearance tab for each and loading the new icon.

After rebuilding them all, I switch Windows Explorer to Large Icons view and take a look at the programs in the Bin folder, but I found that only some of them show the new 256px icon. The others still show the smaller 48px one.

I've checked the Project options again, and they all seem to be the same, so I used Resource Hacker to look at the EXE's. All of them contain 4 icons, named 1, 2, 3, 4, of differing sizes, and they all contain an Icon Group with a MAINICON resource that includes all 4 sizes.

So I'm at a loss as to why some show Large Icons correctly while others don't. Anyone have any thoughts on this?

回答1:

It sounds like you're experiencing Windows caching your icons. All executable files get their icons cached by Windows the first time they're shown, and thus if you change your icon, Windows will still display the old one because it's cached.

You should clear your icon cache. To do this, you need to delete a file which is in a hidden system folder, found at this location:

C:\Users\User-Name\AppData\Local\IconCache.db

Replace "User-Name" with the folder name of your user profile folder. Once you have deleted this, you must log off and back on, or kill / restart the explorer.exe process. After you do this, everything should show correctly.