Inno Setup Usage

From Lazarus wiki
Revision as of 19:13, 31 August 2011 by Lainz (talk | contribs) (added some explanation)

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

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.

<delphi>[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</delphi>

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.

<delphi>Root: HKLM; Subkey: "Software\Classes\.bmp"; ValueType: String; ValueData: "LazPaint.AssocFile.bmp"; Flags: uninsdeletevalue uninsdeletekeyifempty; Tasks: assoc_bmp</delphi>

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.

<delphi>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</delphi>

Finally we need to add the program to the 'Registered Applications':

<delphi>Root: HKLM; Subkey: "Software\RegisteredApplications"; ValueType: String; ValueName: "LazPaint"; ValueData: "Software\LazPaint\Capabilities"; Flags: uninsdeletevalue uninsdeletekeyifempty</delphi>