UserGuide

Inno Setup Script (64-bit apps)

From Xojo Documentation

Inno Setup is a free tool for creating Windows installers. It is a great way to create Windows installers for your desktop apps so that you can easily deploy them. The following script can be used with Inno Setup to create an installer for your 64-bit Windows desktop apps.

To learn more about Inno Setup and other installer options:

Windows Installers

Sample Script

The following script is included with Xojo and located here:

Examples/Platform-Specific/Windows/Making Installers/XojoInstaller64bit.iss

; Sample script for creating an installer for a 64-bit Xojo desktop app
; To use this script, specify the values for the two constants
; below with those for your app and project.
; XojoAppName is the name of the build app without the ".exe" extension.
#define XojoAppName            "EddiesElectronics"
; XojoProjectName is the name of the project file, including its extension.
#define XojoProjectName        "EEDesktop.xojo_binary_project"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID from the menu.) 
AppId={{27EFF741-9A5C-4C19-8841-E9F4B7E6BCFC}
AppName={#XojoAppName}
AppVerName={#XojoAppName} 1.0
AppPublisher=Xojo, Inc.
AppPublisherURL=
AppSupportURL=
AppUpdatesURL=
DefaultDirName={pf}\{#XojoAppName}
DefaultGroupName={#XojoAppName}
; save installer file alongside this script
OutputDir=.  
OutputBaseFilename=Setup{#XojoAppName}
; If you have an End User License Agreement (EULA) that you want the user to agree to before letting the install continue,
; put the path to it here.
LicenseFile=
Compression=lzma
SolidCompression=yes
ChangesAssociations=yes
ArchitecturesInstallIn64BitMode=x64
; Require Windows 7 SP1 or later
MinVersion=6.1.7601

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

; These directories will be created by the installer inside the DefaultDirName
; (defined above).
[Dirs]
Name: "{app}\{#XojoAppName} Libs"
Name: "{app}\{#XojoAppName} Resources"

; These are the files to include.  By default you want to include
; the EXE plus the Libs and Resources folders
; but you can include any other files you like as well.
[Files]
Source: ".\{#XojoAppName}\Desktop\Builds - {#XojoProjectName}\Windows 64 bit\{#XojoAppName}\{#XojoAppName}.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\{#XojoAppName}\Desktop\Builds - {#XojoProjectName}\Windows 64 bit\{#XojoAppName}\*"; DestDir: "{app}\"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\{#XojoAppName}\Desktop\Builds - {#XojoProjectName}\Windows 64 bit\{#XojoAppName}\{#XojoAppName} Libs\*"; DestDir: "{app}\{#XojoAppName} Libs"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\{#XojoAppName}\Desktop\Builds - {#XojoProjectName}\Windows 64 bit\{#XojoAppName}\{#XojoAppName} Resources\*"; DestDir: "{app}\{#XojoAppName} Resources"; Flags: ignoreversion recursesubdirs createallsubdirs

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

; Creates icons/links in the Start Menu and/or the desktop if the user chooses during installation.
[Icons]
Name: "{group}\{#XojoAppName}"; Filename: "{app}\{#XojoAppName}.exe";
Name: "{commondesktop}\{#XojoAppName}"; Filename: "{app}\{#XojoAppName}.exe"; Tasks: desktopicon;

; Give the user the option to run the app after the installation is finished.
[Run]
Filename: "{app}\{#XojoAppName}.exe"; Description: "{cm:LaunchProgram,{#XojoAppName}}"; Flags: nowait postinstall skipifsilent

; This specifies the Visual C++ Windows Runtime Redistributable to also install because
; it is required by Xojo apps made with 2016r1 or later.
[Files]
Source: "C:\Program Files (x86)\Xojo\Xojo 2016r1.1\Extras\Windows Runtime\Installers\VC_redist.x64.exe"; DestDir: {tmp}

[Run]
Filename: {tmp}\VC_redist.x64.exe; Parameters: "/install /quiet /norestart"; StatusMsg: "Installing 64-bit Windows Universal runtime..."; Flags: waituntilterminated


File Type Associations

In order for file type associates to work, you need to include steps in the installer to create the appropriate Registry entries.

First change the [Setup] section directive "ChangesAssociations" to "yes". If you don't do this, the correct icon for the file type likely won't be displayed until the user logs off or restarts the computer.

ChangesAssociations=yes

Now you can add a [Registry] section with the entries as shown below.

[Registry]
Root: HKCR; Subkey: ".myType"; ValueType: string; ValueName: ""; ValueData: "MyAppName"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "MyAppName"; ValueType: string; ValueName: ""; ValueData: "My Program File"; Flags: uninsdeletekey
Root: HKCR; Subkey: "MyAppName\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MyAppFileIcons.ico"
Root: HKCR; Subkey: "MyAppName\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\XojoApp.exe"" ""%1"""

Notes

  • Change ".myType" to the extension you are associating.
  • Change "MyAppName" to a unique internal name for the file type as stored in the registry. You must use a unique name for this so you don't inadvertently overwrite another application's registry key. A good way to create a unique name is to use reverse-DNS format, such as: com.example.myapp
  • "My Program File" above is the name for the file type as shown in Explorer.
  • "DefaultIcon" is the registry key that specifies the filename containing the icon to associate with the file type. For best results use an .ico file. Be sure to include this ico file in the main installer script so that it is available for use. There are free online services than can create an ico file for you from an initial image or icon.
  • "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.

See Also

Create Installer Automatically with IDE Scripting

For a more automated build process you can use an IDE Script Build Step to run Inno Setup with your installer script after each build.

To do this, add an IDE Script step to your project and drag it after the "Build" item in the Windows build settings.

Paste this code into the IDE Script Build Step:

// Run Inno Setup Installer Script
// Paths
Dim innoSetupPath As String
innoSetupPath = """C:\Program Files (x86)\Inno Setup 5/iscc"""
Dim innoSetupProject As String
innoSetupProject = """C:\PathToSetupScript\XojoSetup.iss"""
Dim outputFile As String
outputFile = """C:\PathToScriptOutput\buildoutput.txt"""

// Create Shell command
Dim command As String
command = innoSetupPath + " " + _
innoSetupProject + _
" >" + outputFile

// Send Shell command
Dim result As String
Dim resultCode As Integer
result = DoShellCommand(command, 20000, resultCode)

// Check for error
If resultCode <> 0 Then
Call ShowDialog("Inno Setup Error", "There was an error creating the installer. Refer to buildoutput.txt.", "OK")
End If

You will need to adjust the paths in this script to point to the correct locations on your computer.

See Also

UserGuide:Inno Setup Script (32-bit apps), UserGuide:64-Bit Guidelines topics