14

In the Inno Setup FAQ is an example of how to assign filetypes to my software. Dealing with the registry is no problem.

But how can I provide the user the choice of which filetypes he wants to assign? Let's say, I have written a simple editor for text files and want to ask if the user wants to assign .txt and/or .nfo with my program. A setup-page with checkboxes would be genius.

How to do this with Inno Setup?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
0xDEADBEEF
  • 3,401
  • 8
  • 37
  • 66

3 Answers3

21

Add a 'Task' to the setup, and associate each of the registry entries of your file association with this Task. Eg:

[Tasks]
Name: mypAssociation; Description: "Associate ""myp"" extension"; GroupDescription: File extensions:

[Registry]
Root: HKCR; Subkey: ".myp"; ValueType: string; ValueName: ""; ValueData: "MyProgramFile"; Flags: uninsdeletevalue; Tasks: mypAssociation 
Root: HKCR; Subkey: "MyProgramFile"; ValueType: string; ValueName: ""; ValueData: "My Program File"; Flags: uninsdeletekey; Tasks: mypAssociation
...


See the documentation of 'Tasks' here.

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
  • This worked flawlessly for me as well, thank you! :) – Kaitlyn Aug 29 '15 at 05:05
  • 1
    Just one tweak to this: For a properly localized installer, Description: should be something like `{cm:AssocFileExtension,My App Name,myp}`, which will use the default InnoSetup [custom message](http://www.jrsoftware.org/ishelp/topic_custommessagessection.htm) for "&Associate %1 with the %2 file extension" as translated into the language being used in the installer. – FeRD Jul 16 '19 at 20:03
1

You can find some information about file association in innosetup in a previous answer : Stackoverflow - Inno setup file association

And here, we can find an exemple in order to use this file association in .net program, just by parsing the arguments in the main method : Stackoverflow - Associate a file extension with WPF application

Community
  • 1
  • 1
v20100v
  • 696
  • 4
  • 11
  • 1
    Well, even here, the OP knows how to make the association itself (see the first sentence of this question). The question here was how to make this association conditional in some way. That's why Sertac suggested using `[Tasks]` section and shortened the script from that FAQ (which OP mentioned in their question). So even this adds actually nothing to the *thread*. – TLama Jan 26 '15 at 13:18
0

Using the [Tasks] section is the easiest way to associate files with your application in Inno Setup as @Sertac has said. You should then fill in the details for the extension you want to associate in the [Registry] section. For more info about this check out the Inno Setup FAQ page.

Pavel Vladov
  • 4,707
  • 3
  • 35
  • 39
  • 1
    Your link is somehow broken. But you probably meant [`this FAQ tip`](http://www.jrsoftware.org/isfaq.php#assoc) from which Sertac shown only part in his answer already (hence there is `...` at the bottom of his code example). So, your answer adds actually nothing to this thread. However, dropping a comment with the link to that FAQ might be useful and would be worth to mention. – TLama Jan 24 '15 at 16:07
  • Hi @TLama, yes, you were right about the link. I've corrected it. I too find this link to the FAQ useful, because it explains what all these links in the [Registry] section are all about. – Pavel Vladov Jan 24 '15 at 20:07