Inno Setup Usage
Inno Setup (home) is a program to develop installers for Windows. Is coded in Delphi and has unicode support. Is one of the most often used programs to create setup files alongside with nsis. The advantage of Inno Setup is that support Pascal Scripting.
Download
Download Inno Setup Quick Start Pack Is the recommended download.
Examples
- The Lazarus setup for Windows was created with Inno Setup, you can download the latest snapshot here: lazarus.iss
- Also LazPaint setup was created with it: lazpaint.iss
Both scripts has File Association support and are listed in Default Programs to restore the file associations if needed (Windows 7).
File Association
The file association code is in the [Registry] section of the script.
The first thing we need is each type of association. In this case is for .bmp files. You can see the first line is for the description of the association 'Bitmap'. The second line is the icon for .bmp files in the explorer, the third is the icon for the right clic menu on .bmp files in the explorer, the last is the parameter to open the file.
[Registry]
Root: HKLM; Subkey: "Software\Classes\LazPaint.AssocFile.bmp"; ValueType: String; ValueData: "Bitmap"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\LazPaint.AssocFile.bmp\DefaultIcon"; ValueType: String; ValueData: "{app}\{#MyAppExeName},0"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\LazPaint.AssocFile.bmp\Shell\Open"; ValueName: Icon; ValueType: String; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\LazPaint.AssocFile.bmp\Shell\Open\Command"; ValueType: String; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletekey
That code doesn't associate nothing, the next code is to associate our type 'LazPaint.AssocFile.bmp' with '.bmp'. It is only executed when the task assoc_bmp is selected. Read about tasks in the Inno Setup help.
Root: HKLM; Subkey: "Software\Classes\.bmp"; ValueType: String; ValueData: "LazPaint.AssocFile.bmp"; Flags: uninsdeletevalue uninsdeletekeyifempty; Tasks: assoc_bmp
That's all. Now we have associated .bmp with LazPaint.
Default Programs
Default Programs is used to list the applications that has file association support. Values are the name of the app, a short description and each one of the extensions the program has support.
Root: HKLM; Subkey: "Software\LazPaint"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\LazPaint\Capabilities"; ValueType: String; ValueName: "ApplicationName"; ValueData: "LazPaint"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\LazPaint\Capabilities"; ValueType: String; ValueName: "ApplicationDescription"; ValueData: "A short description..."; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\LazPaint\Capabilities\FileAssociations"; ValueName: ".bmp"; ValueType: String; ValueData: "LazPaint.AssocFile.bmp"; Flags: uninsdeletekey
Finally we need to add the program to the 'Registered Applications':
Root: HKLM; Subkey: "Software\RegisteredApplications"; ValueType: String; ValueName: "LazPaint"; ValueData: "Software\LazPaint\Capabilities"; Flags: uninsdeletevalue uninsdeletekeyifempty