Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File association in Inno Setup

Tags:

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?

like image 586
user1429254 Avatar asked Oct 23 '14 19:10

user1429254


People also ask

How do you create a file association?

Windows allows you to change file associations by going into Settings > Apps > Default Apps and selecting at the bottom the option titled "Choose default apps by file type". This will open a screen that lists all of the configured extensions on the computer and the program associated with them.

What is file type association?

File associations are registry settings that tell Windows what application to use to open files of a certain type. For example, Windows typically launches Notepad.exe when a text (. txt) file is opened.

What is file association fix?

Using File Association Fixer Tool is simplicity in motion; launch, choose the file requiring fixing and then load it. From there, it will restore the associations while keeping the file contents intact. Upon completion of the process, you will be notified to open the file with its intended program.

What is an Inno Setup file?

Inno Setup is a free software script-driven installation system created in Delphi by Jordan Russell. The first version was released in 1997. Inno Setup. Screenshot of the Inno Setup IDE running on Windows 7. Developer(s)


1 Answers

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: "" 

Explanations

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.

add extension in 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 :

Add entry in KHCR\MyMAGIApplication

like image 107
v20100v Avatar answered Sep 19 '22 22:09

v20100v