'Possible to change the application file's icon?

I'm using Inno Setup to create a Windows software installer, and would like to use a custom icon for the distributed exe file (which will be located in C > Program Files > MyProgram ).

So far, I've been able to get the custom icon to work (sort of) for the desktop shortcut, by using the following code, placed under the [Icon] section...

Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\TheIcon.ico";  Tasks: desktopicon

When I say that it "sort of" worked... it did customize the desktop shortcut's icon, but the quality of the icon looks terrible compared to the quality of the original icon.

But the bigger issue is... I can't figure out how to customize the icon for the actual application (exe) file at all, or for the start menu shortcut.

I would have assumed that the following line would do the trick for the application file...

Name: "{pf}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\TheIcon.ico";

And I also assumed that the following code would do the trick for the start menu icon...

Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\TheIcon.ico";

But no dice. It just uses the default icon.

Can anyone tell what I'm doing wrong? I would post the entire script here but it seems that the Stack Overflow code editor doesn't like a bunch of curly brackets over multiple lines (if someone knows a way around that I'll be happy to post the whole script).

And FYI... for this particular project, changing the exe icon prior to running it through Inno Setup doesn't appear to be an option (I tried changing it via Resource Hacker, and although it succeeded in changing the exe's icon, it corrupted the file in the process, to where it wouldn't even run :(

If it's not possible to customize the application file's icon using Inno Setup, then do I have any other options?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source