Radiobuttons with InnoSetup : Define files that will be installed or not - installation

With a single executable file generated with InnoSetup (with "IconMain.ico") and a single uninstall(with a different icon "IconUninst.ico"), I would like to install some files in drive "C" and "K". The user will not be allowed to change drive paths/names, as :
STANDART RADIOBUTTON -
Full installation. Files that will be installed in drive "C:" AND "K:"
- Game.exe --> DRIVE C:\games
- Mapping.exe --> DRIVE C:\Mapping
- Pics.dll --> DRIVE C:\Pics
- AAA.dll --> DRIVE K:\Sounds
- BBB.obj --> DRIVE K:\Sounds
'
ADVANCED RADIONBUTTON -
Partial installation.
The only files that will be installed. (IF user agrees to continue)
- AAA.dll --> DRIVE K:\Sounds
- BBB.obj --> DRIVE K:\Sounds
How can I accomplish that?
Thank you !

To conditionally install a certain file you need to use the Check parameter. You need to return True to the expression or function to install the item, False to skip. The example to your previous assignment is shown in the reference page I've linked in the previous sentence.
So to combine it with custom installation type radio buttons you've mentioned, you just need to make a function that will be assigned to the check and that will return its result depending on selected radio button.
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
; these two items will be installed always
Source: "AAA.dll"; DestDir: "K:\Sounds"
Source: "BBB.obj"; DestDir: "K:\Sounds"
; these three items will be installed only when the IsFullInstallation
; function returns True, what will depend on the selected radio button
Source: "Game.exe"; DestDir: "C:\Games"; Check: IsFullInstallation;
Source: "Mapping.exe"; DestDir: "C:\Mapping"; Check: IsFullInstallation;
Source: "Pics.dll"; DestDir: "C:\Pics"; Check: IsFullInstallation;
[Code]
const
FullDescText =
'Full installation. Files will be installed on drives "C:" and "K:"';
PartDescText =
'Partial installation. Files will be installed on drives "C:" and "K:"';
var
FullRadioButton: TNewRadioButton;
PartRadioButton: TNewRadioButton;
procedure InitializeWizard;
var
CustomPage: TWizardPage;
FullDescLabel: TLabel;
PartDescLabel: TLabel;
begin
CustomPage := CreateCustomPage(wpWelcome, 'Installation type', '');
FullRadioButton := TNewRadioButton.Create(WizardForm);
FullRadioButton.Parent := CustomPage.Surface;
FullRadioButton.Checked := True;
FullRadioButton.Top := 16;
FullRadioButton.Width := CustomPage.SurfaceWidth;
FullRadioButton.Font.Style := [fsBold];
FullRadioButton.Font.Size := 9;
FullRadioButton.Caption := 'Full Installation'
FullDescLabel := TLabel.Create(WizardForm);
FullDescLabel.Parent := CustomPage.Surface;
FullDescLabel.Left := 8;
FullDescLabel.Top := FullRadioButton.Top + FullRadioButton.Height + 8;
FullDescLabel.Width := CustomPage.SurfaceWidth;
FullDescLabel.Height := 40;
FullDescLabel.AutoSize := False;
FullDescLabel.Wordwrap := True;
FullDescLabel.Caption := FullDescText;
PartRadioButton := TNewRadioButton.Create(WizardForm);
PartRadioButton.Parent := CustomPage.Surface;
PartRadioButton.Top := FullDescLabel.Top + FullDescLabel.Height + 16;
PartRadioButton.Width := CustomPage.SurfaceWidth;
PartRadioButton.Font.Style := [fsBold];
PartRadioButton.Font.Size := 9;
PartRadioButton.Caption := 'Partial Installation'
PartDescLabel := TLabel.Create(WizardForm);
PartDescLabel.Parent := CustomPage.Surface;
PartDescLabel.Left := 8;
PartDescLabel.Top := PartRadioButton.Top + PartRadioButton.Height + 8;
PartDescLabel.Width := CustomPage.SurfaceWidth;
PartDescLabel.Height := 40;
PartDescLabel.AutoSize := False;
PartDescLabel.Wordwrap := True;
PartDescLabel.Caption := PartDescText;
end;
function IsFullInstallation: Boolean;
begin
Result := FullRadioButton.Checked;
end;

The easiest way to make conditional installations is to use [Types] and [Components].
[Types]
Name: standard; Description: Standard
Name: partial; Description: Partial
[Components]
Name: game; Description: Full game install; Types: standard
Name: sounds; Description: Sound files; Types: standard partial
[Files]
...; Components: game
...; Components: sounds

Related

Custom TLabel not displaying on FinishedPage in Inno Setup

I must be missing something obvious here. I'm trying to add a link to the release notes onto wpFinished but can't seem to make it show up:
I have a file finishedPage.iss which I include via #include "InnoDialogs\finishedPage.iss";
The file has the following content:
[Run]
Filename: "{app}\bin\{#MyAppExeName}"; \
Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \
Flags: nowait postinstall skipifsilen
[Code]
{ procedures to deal with page interaction }
procedure ReleaseNotesClick(Sender: TObject);
var
errorCode: Integer;
begin
ShellExec('','https://myUrl.com/Release_Notes', '', '', SW_SHOW, ewNoWait, errorCode)
end;
{ build the page }
procedure FinishedPage_Create;
var
ReleaseNotesLink: TLabel;
begin
ReleaseNotesLink := TLabel.Create(WizardForm);
ReleaseNotesLink.Parent := WizardForm.FinishedPage;
ReleaseNotesLink.Caption := 'Read the Releasenotes';
ReleaseNotesLink.Enabled := True;
ReleaseNotesLink.Visible := True;
ReleaseNotesLink.AutoSize := True;
ReleaseNotesLink.Left := WizardForm.FinishedLabel.Left;
ReleaseNotesLink.Top := WizardForm.FinishedLabel.Top + ScaleY(100);
ReleaseNotesLink.OnClick := #ReleaseNotesClick;
ReleaseNotesLink.ParentFont := True;
ReleaseNotesLink.Font.Style := ReleaseNotesLink.Font.Style + [fsUnderline, fsBold];
ReleaseNotesLink.Font.Color := clBlue;
ReleaseNotesLink.Cursor := crHand;
end;
In the CurPageChanged procedure in my main installer file I have:
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpFinished then
begin
FinishedPage_Create();
end;
end;
This compiles just fine, but I can't make it show up. I tried different positions as well, thinking perhaps it's just drawn behind something else. I'm using the same procedure for adding elements to other pages...
Any ideas what I'm missing?
Your label is hidden behind the RunList, which occupies the rest of the page.
You have to shrink the list. For example:
WizardForm.RunList.Height := ScaleY(24);
ReleaseNotesLink.Left := WizardForm.RunList.Left;
ReleaseNotesLink.Top := WizardForm.RunList.Top + WizardForm.RunList.Height + ScaleY(8);

Inno Setup - Multiple software versions in one installation

I need to make a setup with multiple versions of software and i want to make it have the option for portable / install.
I have a customized components page. It should show after info page and then the directory selection page should show once the options are selected. I THINK I have the [Files] and [Tasks] and [Components] sections figured out. It's mainly the code section I am struggling with.
For example if the user selects to install the Pro version by using the radio button, once Next is clicked it should show the directory selection page and then after continuing it should install or extract (depending on portable or install selections). The installer should install/extract the specified version based on specified files marked as Pro (in the [Files] and [Components] sections).
I have tried lots of variations of code but my current variation is below and it does not work (ignore the SelectedValueIndex numbers, I have yet to put the correct value in but I wanted to make sure it would compile first).
I have code for silent switches that i have to link to the radio buttons too but I think that part will work. Its literally just trying to get the selections (radio buttons and check boxes) to work. Also if you select install for one of the versions id like the group box for portable options to be greyed out (un-selectable) and vice versa. At the moment I can't get the radio buttons to have any values they just do nothing.
Simpler explanation:
Lets say there are two versions of an application Free and Pro.
The files that install depend on whether the user selects Free or Pro. (Set in the [Files], and [Components] Sections respectively).
procedure InitializeWizard();
var SystemMenu: HMENU;
begin
{Create Mode Selection Page}
UsagePage := CreateInputOptionPage(wpInfoBefore,
'Mode', 'Select Installation Mode',
'Mode',
True, False);
UsagePage.Add('FreeInstall');
UsagePage.Add('BusinessInstall');
UsagePage.Add('TechnicianInstall');
UsagePage.Add('ProfessionalInstall');
UsagePage.Add('FreePortable');
UsagePage.Add('BusinessPortable');
UsagePage.Add('TechnicianPortable');
UsagePage.Add('ProfessionalPortable');
//
{Set Default Checkbox - Normal Install}
if (FreeInstall)
then
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
if (BusinessInstall)
then
// Set the Respective Checkbox on The Wizard.
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
if (TechnicianInstall)
then
// Set the Respective Checkbox on The Wizard.
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
if (ProfessionalInstall)
then
// Set the Respective Checkbox on The Wizard.
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
{Set Default Checkbox - Portable}
if (FreePortable)
then
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
if (BusinessPortable)
then
// Set the Respective Checkbox on The Wizard.
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
if (TechnicianPortable)
then
// Set the Respective Checkbox on The Wizard.
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
if (ProfessionalPortable)
then
// Set the Respective Checkbox on The Wizard.
UsagePage.SelectedValueIndex := 1
else
UsagePage.SelectedValueIndex := 0;
WizardForm.Caption := '{#MyAppName} v{#MyAppVersion}';
TotalSpace;
WizardForm.DiskSpaceLabel.Hide;
It won't compile like this
Use Check parameter to bind [Files] section entries to the selection on the custom page:
[Files]
Source: "MyProgFree.exe"; DestDir: "{app}"; Check: IsModeSelected(0)
Source: "MyProgPro.exe"; DestDir: "{app}"; Check: IsModeSelected(1)
[Code]
var
UsagePage: TInputOptionWizardPage;
function IsModeSelected(Mode: Integer): Boolean;
begin
Result := (UsagePage.SelectedValueIndex = Mode);
end;
procedure InitializeWizard();
begin
UsagePage :=
CreateInputOptionPage(
wpInfoBefore, 'Mode', 'Select Installation Mode', 'Mode', True, False);
UsagePage.Add('FreeInstall');
UsagePage.Add('ProInstall');
end;

How to get versions of files (exe's and dll's) which are included to Inno Setup installer exe file?

As in topic, is it possible? And, I want to display them on one page of installer if parameter (e.g. parameter passed to exe file) is set to true.
I know how to display some page:
if dev then
PageWersjePlikow :=
CreateOutputMsgMemoPage(
1, 'Wersje plików zawarte w instalatorze',
'Lista plików niewidoczna dla klienta',
'Pliki:', 'TU WPISAĆ WERSJE PLIKÓW');
I have some ideas, but every idea is based on .txt file built while compiling exe installer and then read from it...
Use GetVersionNumbers or GetVersionNumbersString support functions.
The GetVersionNumbersString returns version in format Major.Minor.Rev.Build.
If you need a different format, you need to use GetVersionNumbers and format the version components, the way you need (like Major.Minor.Rev):
function MyGetVersionNumbersString(
const Filename: String; var Version: String): Boolean;
var
MS, LS: Cardinal;
Major, Minor, Rev, Build: Cardinal;
begin
Result := GetVersionNumbers(Filename, MS, LS);
if Result then
begin
Major := MS shr 16;
Minor := MS and $FFFF;
Rev := LS shr 16;
Build := LS and $FFFF;
Version := Format('%d.%d.%d', [Major, Minor, Rev]);
end
end;
Thank you! I have found solution for checking cmd parameter:
function GetParam: Boolean;
var
param: string;
i: integer;
begin
Result := False;
for i:= 0 to ParamCount do
begin
param := ParamStr(i);
if (param = '-p') then
begin
Result := True;
break;
end;
end;
end;
With my function I can just run my installer with '-p' parameter and it will show my page containing information which I want :-)

Get radio button value [INNO SETUP]

I am trying to create a new window at Inno Setup. In this window :
There should be 5 radio button
User must select only one of this choice
When the user click the next button I have to get and save the value of the radio button (on somewhere ?) and give this value to the batch file(which will run) with parameter
I think I should do some action in the function of NextButtonClick but I cannot figure out how can I reach the value of radio buttons and save.
Any help is appreciated.
The Screenshot of that window :
So now on, my code is like below :
#define MyAppName "CDV Client"
#define MyAppVersion "3.6.1 build 2"
#define MyAppPublisher " CDV"
#define MyAppURL "https://example-cm-1"
#define MyAppExeName "example.exe"
[Setup]
AlwaysUsePersonalGroup=true
; 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 inside the IDE.)
AppID={{7C9325AD-6818-42CA-839E}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={code:DriveLetter}:\Tool\CDVClient
DefaultGroupName=Ser
AllowNoIcons=true
OutputBaseFilename=CDVClient_setup
Compression=lzma/Max
SolidCompression=true
SetupLogging=true
PrivilegesRequired=none
DirExistsWarning=yes
AlwaysShowDirOnReadyPage=true
AlwaysShowGroupOnReadyPage=true
[Code]
function DriveLetter(Param: String): String;
begin
if DirExists('d:\') then
Result := 'D'
else if DirExists('e:\') then
Result := 'E'
else
Result := 'C'
end;
var
CDVRadioButton: TNewRadioButton;
ISCRadioButton: TNewRadioButton;
TestRadioButton: TNewRadioButton;
Test2RadioButton: TNewRadioButton;
Test3RadioButton: TNewRadioButton;
lblBlobFileFolder: TLabel;
procedure InitializeWizard;
var
LabelFolder: TLabel;
MainPage: TWizardPage;
FolderToInstall: TNewEdit;
begin
MainPage := CreateCustomPage(wpWelcome, 'Deneme', 'Deneme2');
LabelFolder := TLabel.Create(MainPage);
LabelFolder.Parent := WizardForm;
LabelFolder.Top := 168;
LabelFolder.Left := 6;
LabelFolder.Caption := 'Directory:'
lblBlobFileFolder := TLabel.Create(MainPage);
lblBlobFileFolder.Parent := MainPage.Surface;
lblBlobFileFolder.Top := LabelFolder.Top - 160;
lblBlobFileFolder.Left := LabelFolder.Left;
lblBlobFileFolder.Width := LabelFolder.Width * 5;
lblBlobFileFolder.Caption := 'Please select the convenient extension ';
CDVRadioButton := TNewRadioButton.Create(MainPage);
CDVRadioButton.Parent := MainPage.Surface;
CDVRadioButton.Top := LabelFolder.Top - 120;
CDVRadioButton.Left := LabelFolder.Left;
CDVRadioButton.Width := LabelFolder.Width * 5;
CDVRadioButton.Caption := 'CDV';
CDVRadioButton.Checked := true;
ISCRadioButton := TNewRadioButton.Create(MainPage);
ISCRadioButton.Parent := MainPage.Surface;
ISCRadioButton.Top := LabelFolder.Top - 80;
ISCRadioButton.Left := LabelFolder.Left;
ISCRadioButton.Width := LabelFolder.Width * 5;
ISCRadioButton.Caption := 'ISC';
TestRadioButton := TNewRadioButton.Create(MainPage);
TestRadioButton.Parent := MainPage.Surface;
TestRadioButton.Top := LabelFolder.Top - 40;
TestRadioButton.Left := LabelFolder.Left;
TestRadioButton.Width := LabelFolder.Width * 5;
TestRadioButton.Caption := 'Test1';
Test2RadioButton := TNewRadioButton.Create(MainPage);
Test2RadioButton.Parent := MainPage.Surface;
Test2RadioButton.Top := LabelFolder.Top ;
Test2RadioButton.Left := LabelFolder.Left;
Test2RadioButton.Width := LabelFolder.Width * 5;
Test2RadioButton.Caption := 'Test2';
Test3RadioButton := TNewRadioButton.Create(MainPage);
Test3RadioButton.Parent := MainPage.Surface;
Test3RadioButton.Top := LabelFolder.Top + 40;
Test3RadioButton.Left := LabelFolder.Left;
Test3RadioButton.Width := LabelFolder.Width * 5;
Test3RadioButton.Caption := 'Test3';
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
// I should do something in here but what ? :/
end;
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1
[Files]
; add recursesubdirs
Source: "C:\Program Files\Inno Setup 5\Examples\batu.bat"; DestDir: "{app}"; Flags: overwritereadonly recursesubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
You can check the 'Checked' property of the radio buttons to see which one is selected:
if (CDVRadioButton.Checked) then
begin
Do stuff...
end
else if (ISCRadioButton.Checked) then
begin
Do some other stuff...
end;
HTH

How to show several licenses in the installer

I use the Inno Setup to create installer for my program. In my program I use third-party libraries, so I have to show license information for each of them.
also I want the installer to show certain license files to chosen language.
I know how to switch between license files if I have 1 license form.
I've looked in google for whole day but didn't find anything
how can I show several licenses?
You can make each license file match the language file by removing the LicenseFile directive from [Setup] and putting it in the [Languages] like this:
Name: "english"; MessagesFile: "compiler:Default.isl"; LicenseFile: "English License.rtf"
Name: "chinesesimp"; MessagesFile: "compiler:Languages\ChineseSimp.isl"; LicenseFile: "Chinese SIM License.rtf"
Name: "chinesetrad"; MessagesFile: "compiler:Languages\ChineseTrad.isl"; LicenseFile: "Chinese TRA License.rtf"
etc...
Hope that helps
You can use the CreateOutputMsgMemoPage to create a page with the memo box on. You can then adjust the sizing and add the agree/disagree boxes.
; Shows a new license page for the LGPL with the usual accept/don't acccept options
[Code]
var
LGPLPage: TOutputMsgMemoWizardPage;
LGPLAccept: TNewRadioButton;
LGPLRefuse: TNewRadioButton;
procedure LGPLPageActivate(Sender: TWizardPage); forward;
procedure LGPLAcceptClick(Sender: TObject); forward;
procedure LGPL_InitializeWizard();
var
LGPLText: AnsiString;
begin
// Create the page
LGPLPage := CreateOutputMsgMemoPage(wpLicense, SetupMessage(msgWizardLicense), SetupMessage(msgLicenseLabel), CustomMessage('LGPLHeader'), '');
// Adjust the memo and add the confirm/refuse options
LGPLPage.RichEditViewer.Height := ScaleY(148);
LGPLAccept := TNewRadioButton.Create(LGPLPage);
LGPLAccept.Left := LGPLPage.RichEditViewer.Left;
LGPLAccept.Top := LGPLPage.Surface.ClientHeight - ScaleY(41);
LGPLAccept.Width := LGPLPage.RichEditViewer.Width;
LGPLAccept.Parent := LGPLPage.Surface;
LGPLAccept.Caption := SetupMessage(msgLicenseAccepted);
LGPLRefuse := TNewRadioButton.Create(LGPLPage);
LGPLRefuse.Left := LGPLPage.RichEditViewer.Left;
LGPLRefuse.Top := LGPLPage.Surface.ClientHeight - ScaleY(21);
LGPLRefuse.Width := LGPLPage.RichEditViewer.Width;
LGPLRefuse.Parent := LGPLPage.Surface;
LGPLRefuse.Caption := SetupMessage(msgLicenseNotAccepted);
// Set the states and event handlers
LGPLPage.OnActivate := #LGPLPageActivate;
LGPLAccept.OnClick := #LGPLAcceptClick;
LGPLRefuse.OnClick := #LGPLAcceptClick;
LGPLRefuse.Checked := true;
// Load the LGPL text into the new page
ExtractTemporaryFile('lgpl-3.0.txt');
LoadStringFromFile(ExpandConstant('{tmp}/lgpl-3.0.txt'), LGPLText);
LGPLPage.RichEditViewer.RTFText := LGPLText;
end;
procedure LGPLPageActivate(Sender: TWizardPage);
begin
WizardForm.NextButton.Enabled := LGPLAccept.Checked;
end;
procedure LGPLAcceptClick(Sender: TObject);
begin
WizardForm.NextButton.Enabled := LGPLAccept.Checked;
end;
[Files]
Source: {#Common}Setups\lgpl-3.0.txt; DestDir: {app}; Flags: ignoreversion
[CustomMessages]
LGPLHeader=Please read the following License Agreement. Some components are licensed under the GNU Lesser General Public License.

Resources