Advanced Inno Setup
In this section, we are going to consider some of the relatively common tasks in Inno Setup which require a bit of work beyond the simple Wizard. Inno Setup has an excellent help file as well as a great FAQ section - if what you find here is not enough, Inno Setup help is a good place to start researching!
Registering an OCX file
[Files]
Source: “ComCtl32.ocx”; DestDir: “{sys}”; CopyMode: alwaysskipifsameorolder; Flags: restartreplace sharedfile regserverComment: In the [File] section of the script, put the above code. The above code will put the ocx file into the {sys} folder. If the ocx is not a shared file, you can put it into your own application directory by replacing {sys} with {app}.
Registering a DLL
[Files]
Source: “scrrun.dll”; DestDir: “{sys}”; CopyMode: alwaysskipifsameorolder; Flags: restartreplace sharedfile regserver
Installing fonts
[Files]
Source: “GARA.TTF”; DestDir: “{fonts}”; FontInstall: “Garamond”; Flags: onlyifdoesntexist
Installing VB 6 applications
How to make sure you don’t install if there is already another version of your application installed.
Comment: This requires a little coding. It should show you the true power of Inno setup. Note how the registry values are created and read (you can use this to do other things). You will also learn how to create functions.
[Registry]
Root: HKLM; Subkey: Software\The Application; ValueType: string; ValueName: Installed version; ValueData: “Version number (e.g. 1.1)”; Flags: uninsdeletekey[Code]
function GetInstalledVersion(): String;
var
InstalledVersion: String;
begin
InstalledVersion := ”;
RegQueryStringValue(HKLM, ‘Software\The Application’, ‘Installed version’, InstalledVersion);
Result := InstalledVersion;
end;function InitializeSetup(): Boolean;
var
PrevVer: String;
begin
PrevVer := GetInstalledVersion();
result := true;
if length(PrevVer) > 0 then begin
//Found a previous instillation
MsgBox (’Version ‘ + PrevVer + ‘ of The Application is already installed on this system. In order to run setup, you must first remove the version currently on your system. You can do this through Add/Remove programs from the Windows control panel. Setup will now close.’, mbError, MB_OK);
result := false;
end;
end;
Resources for further information
The above is a very basic introduction. If you need more help, try the following resources. Remember, you can also e-mail me or post a comment here!
- Inno Setup help file
- Inno Setup FAQ
- Rick Borup has written two very good step by step tutorials. They are here and here
- Google your problems!
- Post questions on forums – good one is extreme VB talk.
- Use a software that will allow you to create scripts for you. A free one is Inno Script Generator.
