10
votes

I'm trying to customize the icon that shows in Windows Explorer and in Desktop shortcuts for my Delphi application.

In the Delphi 7 IDE, I have loaded the desired icon in the Application tab of the Project Options dialog. It shows my desired icon as a graphic.

I didn't think it was necessary, but I also set my icon as the TMainForm Icon property.

However, the resulting EXE still shows the default D7 icon. What am I missing?

3
"still shows the default D7 icon" where? - Nick Hodges
@Nick: Like the question says, in Windows Explorer and Desktop shortcuts? <g> - Ken White
"I didn't think it was necessary, but I also set my icon as the TMainForm Icon property." - this is not something to do any more. Remove the form specific ones, or it causes problems in Vista or something (can't remember details, but I fell over it). - mj2008

3 Answers

5
votes

I found it after more hunting. I created a new project by copying an existing project from another folder. I forgot to change the program name at the top of the DPR file to match the name of the new project. Somehow, if a wrong name is used there, it prevents the icon from being changed in the generated EXE file...

3
votes

When you assign an icon to an application, the icon will be embedded in a .res file named identical to the program name (the name mentioned in the first line of the .dpr file). When you change the program name in the .dpr file, delphi creates a new .res file with the new program name and looks for the icon resource in the new res file and finds none, and hence uses the default icon (or a rectangular white box). The old res file which carries the icon resource will no longer be used. In summary, if you change the program name, you will have to re-assign the icon.

2
votes

Maybe the icon cache needs to be deleted. There are many pages about this problem, this link might be useful: http://smallvoid.com/article/windows-icon-cache.html