Search code examples
windowsiconsinno-setuplaunch4j

How can I reference a custom icon for a file association in Inno Setup?


My application creates documents. I want to have a special icon for the documents it creates, other than just the application icon. On OS X, there is a clear way to do this via the Info.plist. In Windows, however, I'm having trouble. I am using Launch4J and Inno Setup.

Inno Setup describes how to specify an icon via a file association. The example uses the application EXE that contains multiple icons, referencing them as 0, 1, 2, etc. However, Launch4J appears to only support creating an EXE with a single icon, the application icon. So this example won't work for me.

Here is my current Icons section:

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

Here is an example file association:

[Registry]
Root: HKCR; Subkey: ".ext"; ValueType: string; ValueName: ""; ValueData: "EXT"; Flags: uninsdeletevalue; Tasks: associateext
Root: HKCR; Subkey: "EXT"; ValueType: string; ValueName: ""; ValueData: "EXT"; Flags: uninsdeletekey; Tasks: associateext
Root: HKCR; Subkey: "EXT\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MyProg.exe,0"; Tasks: associateext
Root: HKCR; Subkey: "EXT\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MyProg.exe"" ""%1"""; Tasks: associateext

How can I reference a custom icon for a file association in Inno Setup? (Or embed multiple icons in a Launch4J EXE?)


Solution

  • You can point any icon file or choose an icon from EXE/DLL file:

    Root: "HKCR"; Subkey: "EXT\DefaultIcon"; ValueType: string; 
     ValueData: """PATH\Icon.file"""; Flags: uninsdeletekey; Tasks: associateext
    

    In your case it could be:

    Root: "HKCR"; Subkey: "EXT\DefaultIcon"; ValueType: string; 
     ValueData: """{app}\MyCustomIcon.ico"""; Flags: uninsdeletekey; Tasks: associateext