Using Resource Hacker for changing the icon after the build
Asked Answered
W

2

14

This question is written in several places (like here and here).

In the second question there is a comment that says to use

ResHacker.exe -addoverwrite "Project.exe", "Project.exe", "ProgramIcon.ico", ICONGROUP, MAINICON, 0

I also tried using -modify instead of -addoverwrite

ResHacker.exe -modify "Project.exe", "Project.exe", "ProgramIcon.ico", ICONGROUP, MAINICON, 0

but the result is the same.

The icon is changed: if I right click on the exe file and check the properties I see that the icon has been changed, but in Windows Explorer I still see the old icon.

If I open it with Resource Hacker (so not using it as command line tool, but as normal GUI tool) I see the correct icon in the "Open file" dialog.

Can anybody suggest a solution? I am trying to use this in a Delphi post build event.

Whitted answered 2/3, 2011 at 9:32 Comment(2)
I suspect that you are seeing the Icon from explorer's cache. If you are doing this in a post-build event, why don't you link the right icon in to begin with?Behring
With same dpr I need to create 2 files with 2 names and 2 icons. (of course I could do it with 2 dpr, but this means maintaining both, while this would be perfect solution). ANYWAY YOU ARE RIGHT IT WAS JUST EXPLORER'S CACHE. If yuo post the answer I will accept it. THanks.Whitted
B
16

I suspect that you are seeing the icon from explorer's icon cache.

Behring answered 2/3, 2011 at 11:53 Comment(4)
Downvote seems a bit odd considering that the OP has confirmed that this is the problem!!Behring
Yeah, it should be explorer's icon cache, the other might be mixed with the browser cache. <g>Hierophant
@Sertac explorer is not a browser, you are thinking of Internet Explorer! <g>Behring
yes of course I mean "Windows Explorer". Yes that was the problem I am now able to acheive my goal.Whitted
K
12

David's right, Explorer's icon cache needs updating.

Add the following command to your batch file after your ResHacker command:

ie4uinit.exe -ClearIconCache

(ie4unit is a built-in command)

No need to restart explorer.

Kirkkirkcaldy answered 15/9, 2013 at 19:25 Comment(1)
I believe you want ie4uinit -show in Windows 10, but ClearIconCache in earlier versions. You can (probably?) just invoke both safely (depending upon your context?).Noxious

© 2022 - 2024 — McMap. All rights reserved.