I am using Inno Setup and am trying to associate a program that is located in the Program Files (x86)
in Windows 7. I have the following:
#define MyAppName "MyView"
#define MyAppExeName "MyView.exe"
[Setup]
AppName={#MyAppName}
[Registry]
Root: HKCR; Subkey: ".mpl"; ValueType: string; ValueName: ""; ValueData: "MyView"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "MyView"; ValueType: string; ValueName: ""; ValueData: "MyView"; Flags: uninsdeletekey
Root: HKCR; Subkey: "MyView\delta.ico"; ValueType: string; ValueName: ""; ValueData: "{app}\GeoView.EXE,0"
Root: HKCR; Subkey: "MyView\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MYVIEW.EXE"" ""%1"""
Any suggestions for why the association is not working?
If you want to associate a program with an extension just add this instruction in your iss file :
In the section
[Setup]
ChangesAssociations = yes
^-Setup will tell Explorer to refresh its file associations information at the end of the installation, and Uninstall will do the same at the end of uninstallation.
And in the section
[Registry]
Root: HKCR; Subkey: ".mpl"; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}"; ValueData: "Program {#MyAppName}"; Flags: uninsdeletekey; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}\DefaultIcon"; ValueData: "{app}\{#MyAppExeName},0"; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}\shell\open\command"; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; ValueType: string; ValueName: ""
Root: HKCR; Subkey: ".magi"; ValueData: "MyMAGIApplication"; ValueType: string; ValueName: ""; Flags: uninsdeletevalue
. This instruction add ".magi" key in the registry, with more accurate in HKEY_CLASSES_ROOT (HKCR). In this instruction we also have ValueName=""
so it get the default value in the registry.
Root: HKCR; Subkey: "MyMAGIApplication"; ValueData: "Program MAGI"; ValueType: string; ValueName: ""; Flags: uninsdeletekey
In order to add the key MyMAGIApplication
in HKCR with the value "Program MAGI".
Root: HKCR; Subkey: "MyMAGIApplication\DefaultIcon"; ValueData: "{app}\MAGI.EXE,0"; ValueType: string; ValueName: ""
In order to associate an icon contains in the executable. "0" indicates that it's the first icon present in the executable MAGI.EXE.
Root: HKCR; Subkey: "MyMAGIApplication\shell\open\command"; ValueData: """{app}\MAGI.EXE"" ""%1"""; ValueType: string; ValueName: ""
In order to add the subkey shell\open\command. With this instruction, Windows is able to launch application MAGI.EXE when an user click on a file with extension ".magi".
And the result in registry :