7

I need the user to be able to double click on a .pdb file and have it open with myPgm.exe.

What is the syntax to associate a file type (myData.pdb) with an executable (myPgm.exe)?

Is it a registry entry?

Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
  • Does this answer your question? [File association in Inno Setup](https://stackoverflow.com/questions/26536030/file-association-in-inno-setup) – StayOnTarget Aug 03 '22 at 17:55

4 Answers4

15

There's an entry for that in the FAQ on the Inno Setup web site. Here is the quote of the relevant section of the FAQ:

Creating File Associations

First set the [Setup] section directive ChangesAssociations to yes. Then create [Registry] entries as shown below.

[Registry]
Root: HKCR; Subkey: ".myp"; ValueType: string; ValueName: ""; ValueData: "MyProgramFile"; Flags: uninsdeletevalue

".myp" is the extension we're associating. "MyProgramFile" is the internal name for the file type as stored in the registry. Make sure you use a unique name for this so you don't inadvertently overwrite another application's registry key.

Root: HKCR; Subkey: "MyProgramFile"; ValueType: string; ValueName: ""; ValueData: "My Program File"; Flags: uninsdeletekey

"My Program File" above is the name for the file type as shown in Explorer.

Root: HKCR; Subkey: "MyProgramFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MYPROG.EXE,0"

"DefaultIcon" is the registry key that specifies the filename containing the icon to associate with the file type. ",0" tells Explorer to use the first icon from MYPROG.EXE. (",1" would mean the second icon.)

Root: HKCR; Subkey: "MyProgramFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MYPROG.EXE"" ""%1"""

"shell\open\command" is the registry key that specifies the program to execute when a file of the type is double-clicked in Explorer. The surrounding quotes are in the command line so it handles long filenames correctly.

Craig McQueen
  • 41,871
  • 30
  • 130
  • 181
  • 1
    this should be the accepted answer. As instead of linking to other pages, it explains clearly what steps should have been taken to register a file extension. – Tony Dec 01 '16 at 11:36
3

A File association is a series of Registry entries. For more info, take a look at How to Use File Associations Microsoft Sample.

If you don't want to create system-wide file associations, you can create specific user file associations too.

To create registry entries from your script, read the ISS Documentation: Registry Section. If you find any problems come back with a more specific question.

Community
  • 1
  • 1
jachguate
  • 16,976
  • 3
  • 57
  • 98
1

that works well for me. just rename MYEXTENSION

[Registry]
Root: HKA ; Subkey: "Software\Classes\.MYEXTENSION"; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""
Root: HKA ; Subkey: "Software\Classes\{#MyAppName}"; ValueData: "{app}\{#MyAppExeName}";  Flags: uninsdeletekey; ValueType: string; ValueName: ""
Root: HKA ; Subkey: "Software\Classes\{#MyAppName}\DefaultIcon"; ValueData: "{app}\{#MyAppExeName},0"; ValueType: string;  ValueName:""
Root: HKA ; Subkey: "Software\Classes\{#MyAppName}\shell\open\command"; ValueData: """{app}\{#MyAppExeName}"" ""%1""";  ValueType: string; ValueName: ""
Zen Of Kursat
  • 2,672
  • 1
  • 31
  • 47
0
#define MyAppAssocExt ".mp3"

and

[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""

[Icons]
Name: "{group}\도깨비 플레이어"; Filename: "{app}\XMPlayer.exe"
Name: "{userdesktop}\도깨비 플레이어"; Filename: "{app}\XMPlayer.exe"; WorkingDir: "{app}"; IconFilename: "{app}\XMPlayer.exe";
Name: "{group}\{cm:UninstallProgram,Goblin Player}"; Filename: "{uninstallexe}";  
Goblin
  • 1
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 17 '22 at 08:35