Difference between revisions of "Inno Setup Usage"

From Lazarus wiki
Jump to navigationJump to search
Line 67: Line 67:
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]
 
[[Category:Windows]]
 
[[Category:Windows]]
 +
[[Category:PascalScript]]

Revision as of 10:00, 20 April 2013

Inno Setup (home) is a program that lets you create Windows installers for your programs. It is coded in Delphi and has Unicode support. It is one of the most often used programs to create setup files (alongside with nsis). The advantage of Inno Setup is that it supports Pascal Scripting for more advanced tasks (although the built in capabilities are already very extensive).

Like nsis, Inno Setup uses script files (.iss) to indicate what files to install and where. While you can create these with a simple text editor, there are some IDEs for Inno Setup that provide easier editing.

Inno Setup comes with extensive help on the syntax of the script file.

Features

Features:

  • Inno supports all versions of Windows in use today -- Windows 95, 98, ME, NT4, 2000, 2003, XP, Vista, 7, 8. The latest version that can create installers for Windows versions before Windows 2000 is version 5.4. See [1]
  • It can compare file version info, replace in-use files, use shared file counting.
  • It can register DLL/OCXs and type libraries
  • It can install fonts.
  • It can create shortcuts anywhere, including in the Start Menu and on the desktop.
  • It can create registry and .INI entries
  • It has integrated Pascal scripting engine that allows e.g. manipulation of COM/ActiveX objects (e.g. MS Word), setting firewall rules etc.
  • It supports multilingual installs
  • It supports passworded and encrypted installs
  • It supports silent install and uninstall.

Inno Setup for Linux/OSX?

Occassionally, on forums and mailing lists, people ask why there is no Inno Setup for OSX or Linux. However, many people agree that you should use the distribution package manager format (e.g. .rpm, .deb) for Linux and the standard OSX way (e.g. .dmg disk images with the Apple-provided tools) for that; see this article for details. See e.g. this forum discussion for an example.

Download

Download Inno Setup Quick Start Pack is the recommended download. It contains Inno Setup, some IDEs and a preprocessor.

Examples

  • The Lazarus setup for Windows was created with Inno Setup. This script includes PascalScript sections used to customize the installer, which may serve as inspiration for your own installers. You can download the latest version of the install script here: lazarus.iss. If you use SVN releases, the file can be found in $(LazarusDir)\tools\install\win\lazarus.iss

Both scripts have File Association support and are listed in Default Programs to restore the file associations if needed (Windows 7).

Below we show some example of Inno Setup usage. Please have a look at their extensive help files and web site for information on how to perform other tasks.

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 the example below, the type 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 anything, the following 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 our program (LazPaint in the example).

Default Programs

Default Programs is used to list the applications that have 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