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
Related
I want to program an installer that will install certain programs by selecting a user. Every user has defined assignments which program should be installed.
For now, you have to use the components section to configure the programs. But my goal is to configure it with a text file.
Example for text file could be like:
User1 User2 User3 User4
Program 1 x x x x
Program 2 x x
Program 3 x x
Here is my code:
[Types]
Name: "User1"; Description: "User 1"
Name: "User2"; Description: "User 2"
Name: "User3"; Description: "User 3"
Name: "User4"; Description: "User 4"
Name: "Custom"; Description: "Custom"
Name: "Random"; Description:"Random"; Flags: iscustom
[Components]
Name: "Select"; Description: "Alle auswählen:"; Types: User1 User2 User3 User4
Name: "Select\Program_1"; Description: "Program_1"; Types: User1 User2 User3 User4
Name: "Select\Program_2"; Description: "Program_2"; Types: User2 User4
Name: "Select\Program_3"; Description: "Program_3"; Types: User1 User3
[Files]
Source: "TEST \Software\x64\Program_1"; DestDir: "{app}\Program_1"; \
Flags: ignoreversion recursesubdirs; Components: Select\Program_1;
Source: "TEST \Software\x64\Program_2"; DestDir: "{app}\Program_2"; \
Flags: ignoreversion recursesubdirs; Components: Select\Program_2;
Source: "TEST \Software\x64\Program_3"; DestDir: "{app}\Program_3"; \
Flags: ignoreversion recursesubdirs; Components: Select\Program_3;
[Code]
var
TypesPage: TWizardPage;
User1_Button: TNewRadioButton;
User2_Button: TNewRadioButton;
User4_Button: TNewRadioButton;
User3_Button: TNewRadioButton;
Custom_Button: TNewRadioButton;
procedure InitializeWizard();
begin
{ Create custom "types" page }
TypesPage := CreateInputOptionPage(wpSelectDir,
'Select User', '' ,
'Please select the right User',true,false);
User1_Button := TNewRadioButton.Create(TypesPage);
User1_Button.Parent := TypesPage.Surface;
User1_Button.Caption := 'User 1';
User1_Button.Top := 50;
User1_Button.Height := ScaleY(User1_Button.Height);
User1_Button.Checked := (WizardForm.TypesCombo.ItemIndex = 0);
User2_Button := TNewRadioButton.Create(TypesPage);
User2_Button.Parent := TypesPage.Surface;
User2_Button.Caption := 'User 2';
User2_Button.Height := ScaleY(User2_Button.Height);
User2_Button.Top := User1_Button.Top + User1_Button.Height + ScaleY(16);
User2_Button.Checked := (WizardForm.TypesCombo.ItemIndex = 1);
User3_Button := TNewRadioButton.Create(TypesPage);
User3_Button.Parent := TypesPage.Surface;
User3_Button.Caption := 'User 3';
User3_Button.Height := ScaleY(User3_Button.Height);
User3_Button.Top := User2_Button.Top + User2_Button.Height + ScaleY(16);
User3_Button.Checked := (WizardForm.TypesCombo.ItemIndex = 2);
User 4_Button := TNewRadioButton.Create(TypesPage);
User 4_Button.Parent := TypesPage.Surface;
User 4_Button.Caption := 'User 4';
User 4_Button.Height := ScaleY(User4_Button.Height);
User 4_Button.Top := User3_Button.Top + User3_Button.Height + ScaleY(16);
User 4_Button.Checked := (WizardForm.TypesCombo.ItemIndex = 3);
Custom_Button := TNewRadioButton.Create(TypesPage);
Custom_Button.Parent := TypesPage.Surface;
Custom_Button.Caption := 'Custom';
Custom_Button.width := 200;
Custom_Button.Height := ScaleY(Custom_Button.Height);
Custom_Button.Top := User4_Button.Top + User4_Button.Height + ScaleY(16);
Custom_Button.Checked := (WizardForm.TypesCombo.ItemIndex = 4);
WizardForm.TypesCombo.Visible := False; { Dropdown List removed }
WizardForm.IncTopDecHeight(WizardForm.ComponentsList,
-(WizardForm.ComponentsList.Top-WizardForm.TypesCombo.Top));
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = TypesPage.ID then
begin
if User1_Button.Checked then WizardForm.TypesCombo.ItemIndex :=0
else
if User2_Button.Checked then WizardForm.TypesCombo.ItemIndex := 1
else
if User3_Button.Checked then WizardForm.TypesCombo.ItemIndex := 2
else
if User4_Button.Checked then WizardForm.TypesCombo.ItemIndex := 3
else
if Custom_Button.Checked then WizardForm.TypesCombo.ItemIndex := 4;
WizardForm.TypesCombo.OnChange(WizardForm.TypesCombo);
end;
Result:= true;
end;
As you do not seem to care about the configuration file format, let's pick INI file, as Inno Setup has functions to parse it:
[Users]
user1=Program1,Program3
user2=Program1,Program2
user3=Program1,Program3
user4=Program1,Program2
Then the following script will do:
[Types]
Name: "user1"; Description: "User 1"
Name: "user2"; Description: "User 2"
Name: "user3"; Description: "User 3"
Name: "user4"; Description: "User 4"
[Files]
Source: "TEST \Software\x64\Program_1"; DestDir: "{app}\Program_1"; \
Flags: ignoreversion recursesubdirs; Check: ShouldInstallProgram('Program1')
Source: "TEST \Software\x64\Program_2"; DestDir: "{app}\Program_2"; \
Flags: ignoreversion recursesubdirs; Check: ShouldInstallProgram('Program2')
Source: "TEST \Software\x64\Program_3"; DestDir: "{app}\Program_3"; \
Flags: ignoreversion recursesubdirs; Check: ShouldInstallProgram('Program3')
[Code]
function ShouldInstallProgram(ProgramName: string): Boolean;
var
UserName: string;
ProgramsStr: string;
Programs: TStringList;
begin
UserName := WizardSetupType(False);
ProgramsStr :=
GetIniString('Users', UserName, '', ExpandConstant('{src}\UserPrograms.ini'));
Programs := TStringList.Create;
Programs.CommaText := ProgramsStr;
Result := (Programs.IndexOf(ProgramName) >= 0);
Programs.Free;
end;
Type names must be lowercase for this to work. And casing of program names matter.
As the code now actually does not use the [Types] at all, you can replace the WizardSetupType with direct check to your custom page selection. And you can remove the redundant [Types] section and your NextButtonClick event function.
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);
Hello i am trying to make an installer using INNO SETUP, when i started to use ISSkin Code Inno setup send me an error mesage DUPLICATE IDENTIFIER 'INITIALIZESETUP' I would like to know what i have to change to my code to make it work.
I was reading at internet and i found a program called IS Script Joiner, i used it but it doesnt work.
Here is my Inno Code:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Myprogram"
#define MyAppVersion "2.8"
#define MyAppPublisher "Myprogram"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "program.exe"
#define ISSI_WizardSmallBitmapImage "wpBanner.bmp"
#define ISSI_WizardSmallBitmapImage_x 495
#define ISSI_WizardSmallBitmapImage_Align
#define ISSI_IncludePath "C:\ISSI"
#include ISSI_IncludePath+"\_issi.isi"
[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 inside the IDE.)
AppId={{2A8CE1DB-2FDB-4CAA-8A2C-0FE3DB8A500D}
AppName=Myprogram
AppVersion=2.8
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher=Myprogram
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\Myprogram
DefaultGroupName={#MyAppName}
LicenseFile=C:\Libraries\EULA.rtf
OutputDir=C:\Users\Hans Lopez\INNO SETUPS
OutputBaseFilename=programoutput
SetupIconFile=C:\Libraries\Icon.ico
Compression=lzma/Max
SolidCompression=true
WizardImageFile=C:\InstallMlockPackage\Setupbanner.bmp
AppVerName=2.8
DirExistsWarning=yes
VersionInfoProductName=Myprogram
VersionInfoProductVersion=2.8
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
[Dirs]
Name: "{app}" ; Permissions: everyone-full
Name: {sd}\myprogramfolder; Permissions: everyone-full;
[Code]
//===================================================================Verify if Installed===============================================================================
function GetUninstallString: string;
var
sUnInstPath: string;
sUnInstallString: String;
begin
Result := '';
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;
function IsUpgrade: Boolean;
begin
Result := (GetUninstallString() <> '');
end;
function InitializeSetup: Boolean;
var
V: Integer;
iResultCode: Integer;
sUnInstallString: string;
begin
Result := True; // in case when no previous version is found
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\ {2A8CE1DB-2FDB-4CAA-8A2C-0FE2DB8A500D}_is1', 'UninstallString') then //Your App GUID/ID
begin
V := MsgBox(ExpandConstant('Myprogram is Already installed, Do you want to continue?'), mbInformation, MB_YESNO); //Custom Message if App installed
if V = IDYES then
begin
sUnInstallString := GetUninstallString();
sUnInstallString := RemoveQuotes(sUnInstallString);
Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
Result := True; //if you want to proceed after uninstall
//Exit; //if you want to quit after uninstall
end
else
Result := False; //when older version present and not uninstalled
end;
end;
//====================================================================Unistall and Delete Everything==================================================================
procedure DeleteBitmaps(ADirName: string);
var
FindRec: TFindRec;
begin
if FindFirst(ADirName + '\*.*', FindRec) then begin
try
repeat
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin
if (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin
DeleteBitmaps(ADirName + '\' + FindRec.Name);
RemoveDir(ADirName + '\' + FindRec.Name);
end;
end else if Pos('.bmp', AnsiLowerCase(FindRec.Name)) > 0 then
DeleteFile(ADirName + '\' + FindRec.Name);
until not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then begin
if MsgBox('Do you want to delete all data files?', mbConfirmation,
MB_YESNO) = IDYES
then begin
DeleteBitmaps(ExpandConstant('{app}'));
end;
end;
end;
//===========================================================ISSKinCODE=============================================================================
// Importing LoadSkin API from ISSkin.DLL
procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
external 'LoadSkin#files:isskin.dll stdcall';
// Importing UnloadSkin API from ISSkin.DLL
procedure UnloadSkin();
external 'UnloadSkin#files:isskin.dll stdcall';
// Importing ShowWindow Windows API from User32.DLL
function ShowWindow(hWnd: Integer; uType: Integer): Integer;
external 'ShowWindow#user32.dll stdcall';
function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('iTunesB.msstyles');
LoadSkin(ExpandConstant('{tmp}\iTunesB.msstyles'), '');
Result := True;
end;
procedure DeinitializeSetup();
begin
// Hide Window before unloading skin so user does not get
// a glimpse of an unskinned window before it is closed.
ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0);
UnloadSkin();
end;
/////////////////////////////////////////////////////////////ENDCODE/////////////////////////////////////////////////////////////////////////////////////////////////
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "C:\My program\program.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Program Files\C:\My program\*"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\programfolder\*"; DestDir: "{sd}\Myprogramfolder"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ISSkin.dll; DestDir: {app}; Flags: dontcopy
Source: "C:\InstallMlockPackage\ISSkin\iTunesB\iTunesB\iTunesB.msstyles"; DestDir: " {tmp}"; Flags: dontcopy
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: " {app}\icon.ico" ;
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"; IconFilename: "{app}\icon.ico" ;
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; IconFilename: "{app}\icon.ico" ;
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\icon.ico" ;
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icon.ico" ;
Name: {group}\Uninstall =ISSkin; Filename: {app}\unins000.exe
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram, {#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
Thank You very Much for Your Help
Relocate the two calls to the ISSkin DLL from where they are now (above the second InitializeSetup) to just above the first InitializeSetup declaration.
// Importing LoadSkin API from ISSkin.DLL
procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
external 'LoadSkin#files:isskin.dll stdcall';
// Importing UnloadSkin API from ISSkin.DLL
procedure UnloadSkin();
external 'UnloadSkin#files:isskin.dll stdcall';
Change the first InitializeSetup code to include the calls to extract and load the skin (from the second InitializeSetup).
function InitializeSetup: Boolean;
var
V: Integer;
iResultCode: Integer;
sUnInstallString: string;
begin
// These two lines moved from second InitializeSetup declaration before it
// was removed.
ExtractTemporaryFile('iTunesB.msstyles');
LoadSkin(ExpandConstant('{tmp}\iTunesB.msstyles'), '');
Result := True; // in case when no previous version is found
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\ {2A8CE1DB-2FDB-4CAA-8A2C-0FE2DB8A500D}_is1', 'UninstallString') then //Your App GUID/ID
begin
V := MsgBox(ExpandConstant('Myprogram is Already installed, Do you want to continue?'), mbInformation, MB_YESNO); //Custom Message if App installed
if V = IDYES then
begin
sUnInstallString := GetUninstallString();
sUnInstallString := RemoveQuotes(sUnInstallString);
Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
Result := True; //if you want to proceed after uninstall
//Exit; //if you want to quit after uninstall
end
else
Result := False; //when older version present and not uninstalled
end;
end;
Remove the second InitializeSetup code entirely.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am making an installer that needs to edit an INI file during the installation. In this case I need to edit only two keys from that ini file.
These two:
filename: rev.ini; Section: Emulator; Key: Language;
filename: rev.ini; Section: steamclient; Key: PlayerName;
I Want The installer to give me the option to select the laguage or use the default language that I already selected from the start in the lenguage menu, and for the PlayerName. Give the option to write any name i want. I didnt see anything like this. only read or put established values in inifiles.
this is my code:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#include "botva2.iss"
#include "BASS_Module.iss"
#define MyAppName "XXX"
#define MyAppVersion "XXX"
#define MyAppPublisher "XXX"
#define MyAppURL "example.com"
[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 inside the IDE.)
AppID={{AA8DB34C-8DE2-468C-8A3A-0DADD1A9C38E}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\
DefaultGroupName={#MyAppName}
LicenseFile=Log1.rtf
InfoBeforeFile=Log2.rtf
InfoAfterFile=Log3.rtf
OutputDir=Output Installer\
OutputBaseFilename=XXX 2xxx-2xxx
SetupIconFile=xxx.ico
Compression=lzma2/Ultra64
SolidCompression=true
InternalCompressLevel=Ultra64
Uninstallable=false
WizardImageFile=fondosetup.bmp
WizardSmallImageFile=0.bmp
CreateAppDir=true
UsePreviousAppDir=true
DirExistsWarning=no
AllowCancelDuringInstall=false
[Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
[CustomMessages]
default.AppCheckError=xxx was not found, please select the Installation Folder of xxx!
spanish.AppCheckError=xxx no fué encontrado, porfavor selecciona la Carpeta de Instalación de xxx!
french.AppCheckError=xxx n'a pas été trouvé, s'il vous plaît sélectionnez le dossier d'installation de xxx!
german.AppCheckError=xxx nicht gefunden wurde, wählen Sie bitte das Installationsverzeichnis von xxx!
catalan.AppCheckError=xxx no s'ha trobat, si us plau, seleccioneu la carpeta d'instal · lació de xxx!
italian.AppCheckError=xxx non è stato trovato, si prega di selezionare la cartella di installazione di xxx!
portuguese.AppCheckError=xxx não foi encontrado, selecione a pasta de instalação do xxx!
[Files]
Source: "xxx\*"; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: ISSkin.dll; DestDir: {tmp}; Flags: dontcopy;
Source: Styles\LegendsIV.cjstyles; DestDir: {tmp}; Flags: dontcopy
Source: IsUtilsHb.dll; DestDir: {tmp}; Flags: dontcopy;
Source: SplashScreen.png; DestDir: {tmp}; Flags: dontcopy;
Source: "BASS_Files\*"; DestDir: {tmp}; Flags: dontcopy
Source: Music.mp3; DestDir: {tmp}; Flags: dontcopy
Source: logo.png; Flags: dontcopy; DestDir: {tmp};
Source: ISLogo.dll; Flags: dontcopy; DestDir: {tmp};
; --- Generated by InnoSetup Script Joiner version 3.0, Jul 22 2009, (c) Bulat Ziganshin <Bulat.Ziganshin#gmail.com>. More info at http://issjoiner.codeplex.com/
; --- Source: Verificar ExE.iss ------------------------------------------------------------
[code]
function NextButtonClick1(PageId: Integer): Boolean;
begin
Result := True;
if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}\left4dead2.exe')) then begin
MsgBox(ExpandConstant('{cm:AppCheckError}'), mbInformation, MB_OK);
Result := False;
exit;
end;
end;
[Setup]
; --- Source: About.iss ------------------------------------------------------------
[Code]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
var
AboutButton: TNewButton;
URLLabel: TNewStaticText;
procedure AboutButtonClick(Sender: TObject); forward;
procedure URLLabelClick(Sender: TObject); forward;
procedure RedesignWizardForm;
begin
{ AboutButton }
AboutButton := TNewButton.Create(WizardForm);
with AboutButton do
begin
Name := 'AboutButton';
Parent := WizardForm;
Left := ScaleX(10);
Top := ScaleY(327);
Width := ScaleX(75);
Height := ScaleY(23);
Caption := 'Info'; // aqui se escribe lo que quiero ver en el about
OnClick := #AboutButtonClick;
end;
{ URLLabel }
URLLabel := TNewStaticText.Create(WizardForm);
with URLLabel do
begin
Name := 'URLLabel';
Parent := WizardForm;
Cursor := crHand;
Caption := 'WEB'; // nombre q desea poner q redirecciona al enlace
Font.Color := clRed; // color
Font.Height := -11;
Font.Name := 'Tele-Marines'; //nombre del font
ParentFont := False;
OnClick := #URLLabelClick;
Left := ScaleX(105);
Top := ScaleY(335);
Width := ScaleX(97);
Height := ScaleY(14);
end;
AboutButton.TabOrder := 5;
URLLabel.TabOrder := 6;
end;
procedure URLLabelClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExecAsOriginalUser('open', 'www.example.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end; //aqui ponen el enlace de su perfil o pagina
procedure AboutButtonClick(Sender: TObject);
begin
MsgBox('Version 2xxx XXX', mbInformation, mb_Ok);
end; //edit the version file here
procedure InitializeWizard2();
begin
RedesignWizardForm;
end;
[Setup]
; --- Source: Audio.iss ------------------------------------------------------------
[code]
procedure InitializeWizard3();
begin
ExtractTemporaryFile('BASS.dll');
ExtractTemporaryFile('Music.mp3');
BASS_Init(ExpandConstant('{tmp}\Music.mp3')) // se copea en los temporarles de tu pc
end;
[Setup]
; --- Source: LOGO XXX.iss ------------------------------------------------------------
[Code]
procedure Logo_Init(Wnd :HWND); external 'ISLogo_Init#files:ISLogo.dll stdcall';
procedure Logo_Draw(FileName: PChar; X, Y: Integer); external 'ISLogo_Draw#files:ISLogo.dll stdcall';
procedure Logo_Free(); external 'ISLogo_Free#files:ISLogo.dll stdcall';
procedure InitializeWizard4();
var
LogoPanel: TPanel;
begin
LogoPanel := TPanel.Create(WizardForm);
with LogoPanel do begin
Top := 326;
Left := 140;
Width := 100;
Height := 37;
Parent := WizardForm;
BevelOuter := bvNone;
end
ExtractTemporaryFile('logo.png');
Logo_Init(LogoPanel.Handle)
Logo_Draw (ExpandConstant('{tmp}\logo.png'), 0 , 0);
end;
[Setup]
; --- Source: Skin Setup.iss ------------------------------------------------------------
[Code]
// Importing LoadSkin API from ISSkin.DLL
procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
external 'LoadSkin#files:isskin.dll stdcall';
// Importing UnloadSkin API from ISSkin.DLL
procedure UnloadSkin();
external 'UnloadSkin#files:isskin.dll stdcall';
// Importing ShowWindow Windows API from User32.DLL
function ShowWindow(hWnd: Integer; uType: Integer): Integer;
external 'ShowWindow#user32.dll stdcall';
function InitializeSetup5(): Boolean;
begin
ExtractTemporaryFile('LegendsIV.cjstyles');
LoadSkin(ExpandConstant('{tmp}\LegendsIV.cjstyles'), '');
Result := True;
end;
procedure DeinitializeSetup5();
begin
// Hide Window before unloading skin so user does not get
// a glimse of an unskinned window before it is closed.
ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0);
UnloadSkin();
end;
[Setup]
; --- Source: Splashpng.iss ------------------------------------------------------------
[Code]
function SplashScreen(hWnd: Integer; pathPng: String; nSleep: Integer): Integer;
external 'SplashScreen#files:IsUtilsHb.dll stdcall';
procedure InitializeWizard6();
var SplashFileName: String;
begin
SplashFileName := ExpandConstant('{tmp}\SplashScreen.png');
ExtractTemporaryFile('SplashScreen.png');
SplashScreen (StrToInt(ExpandConstant('{hwnd}')), SplashFileName, 2000);
end;
[Setup]
; --- Source: Texto Transparente Banner.iss ------------------------------------------------------------
[code]
var
PageNameLabel, PageDescriptionLabel: TLabel;
procedure InitializeWizard7();
begin
PageNameLabel := TLabel.Create(WizardForm);
with PageNameLabel do
begin
Left := ScaleX(10); // mover el titulo de arriba (menor izq o mayor der)
Top := ScaleY(10);
Width := ScaleX(300); // ancho del titulo de texto arriba
Height := ScaleY(14); // altura del titulo de texto de arriba
AutoSize := False;
WordWrap := True;
Font.Color := clWhite; // color de texto
Font.Style := [fsBold];
ShowAccelChar := False;
Transparent := True;
Parent := WizardForm.MainPanel;
end;
PageDescriptionLabel := TLabel.Create(WizardForm);
with PageDescriptionLabel do
begin
Left := ScaleX(15); // mover la descripcion de abajo (menor izq o mayor der)
Top := ScaleY(25);
Width := ScaleX(475); // ancho de la descripcion de texto abajo
Height := ScaleY(30); // altura de la descripcion de texto abajo
AutoSize := False;
WordWrap := True;
Font.Color := clWhite; // color de texto
ShowAccelChar := False;
Transparent := True;
Parent := WizardForm.MainPanel;
end;
with WizardForm do
begin
PageNameLabel.Hide;
PageDescriptionLabel.Hide;
with MainPanel do
begin
with WizardSmallBitmapImage do
begin
Left := ScaleX(0); // mover la imagen (menor izq o mayor der)
Top := ScaleY(0);
Width := Mainpanel.Width;
Height := MainPanel.Height;
end;
end;
end;
end;
procedure CurPageChanged7(CurPageID: Integer);
begin
PageNameLabel.Caption := WizardForm.PageNameLabel.Caption;
PageDescriptionLabel.Caption := WizardForm.PageDescriptionLabel.Caption;
end;
[Setup]
; --- Source: Texto Transparente Menú.iss ------------------------------------------------------------
[code]
function NextButtonClick8(CurPageID: Integer): Boolean;
begin
Result := True;
end;
function GetCustomSetupExitCode8(): Integer;
begin
Result := 1;
end;
procedure InitializeWizard8();
var
WLabel1, WLabel2,
FLabel1, FLabel2: TLabel;
begin
WizardForm.WelcomeLabel1.Hide;
WizardForm.WelcomeLabel2.Hide;
WizardForm.FinishedHeadingLabel.Hide;
WizardForm.FinishedLabel.Hide;
WizardForm.WizardBitmapImage.Width := 500; // tamaño de imagen bienvendia ancho
WizardForm.WizardBitmapImage.Height := 315; // tamaño de imagen bienvendia altura
WLabel1 := TLabel.Create(WizardForm); // PAGINA BIENVENIDO..
WLabel1.Left := ScaleX(40); // mover el titulo de arriba (menor izq o mayor der)
WLabel1.Top := ScaleY(30);
WLabel1.Width := ScaleX(301); // ancho del cuadro de texto arriba
WLabel1.Height := ScaleY(65); // altura del cuadro de texto de arriba
WLabel1.AutoSize := False;
WLabel1.WordWrap := True;
WLabel1.Font.Name := 'Arial'; // nombre del font
WLabel1.Font.Size := 13; // tamaño de texto
WLabel1.Font.Style := [fsBold];
WLabel1.Font.Color:= clWhite; // color de texto
WLabel1.ShowAccelChar := False;
WLabel1.Caption := WizardForm.WelcomeLabel1.Caption;
WLabel1.Transparent := True;
WLabel1.Parent := WizardForm.WelcomePage;
WLabel2 :=TLabel.Create(WizardForm);
WLabel2.Top := ScaleY(110);
WLabel2.Left := ScaleX(40); // mover el titulo de abajo (menor izq o mayor der)
WLabel2.Width := ScaleX(301); // ancho del cuadro de texto abajo
WLabel2.Height := ScaleY(300); // altura del cuadro de texto de abajo
WLabel2.AutoSize := False;
WLabel2.WordWrap := True;
WLabel2.Font.Name := 'arial'; // nombre del font
WLabel2.Font.Color:= clWhite; // color de texto
WLabel2.ShowAccelChar := False;
WLabel2.Caption := WizardForm.WelcomeLabel2.Caption;
WLabel2.Transparent := True;
WLabel2.Parent := WizardForm.WelcomePage;
WizardForm.WizardBitmapImage2.Width := 500; // tamaño de imagen final ancho
WizardForm.WizardBitmapImage2.Height := 315; // tamaño de imagen final altura
FLabel1 := TLabel.Create(WizardForm); // PAGINA FINAL..
FLabel1.Left := ScaleX(40); // mover el titulo de arriba (menor izq o mayor der)
FLabel1.Top := ScaleY(100);
FLabel1.Width := ScaleX(301); // ancho del cuadro de texto arriba
FLabel1.Height := ScaleY(75); // altura del cuadro de texto de arriba
FLabel1.AutoSize := False;
FLabel1.WordWrap := True;
FLabel1.Font.Name := 'arial'; // nombre del font
FLabel1.Font.Size := 16; // tamaño de texto
FLabel1.Font.Style := [fsBold];
FLabel1.Font.Color:= clWhite; // color de texto
FLabel1.ShowAccelChar := False;
FLabel1.Caption := WizardForm.FinishedHeadingLabel.Caption;
FLabel1.Transparent := True;
FLabel1.Parent := WizardForm.FinishedPage;
FLabel2 :=TLabel.Create(WizardForm);
FLabel2.Top := ScaleY(110);
FLabel2.Left := ScaleX(40); // mover el titulo de abajo (menor izq o mayor der)
FLabel2.Width := ScaleX(301); // ancho del cuadro de texto abajo
FLabel2.Height := ScaleY(300); // altura del cuadro de texto de abajo
FLabel2.AutoSize := False;
FLabel2.WordWrap := True;
FLabel2.Font.Name := 'arial'; // nombre del font
FLabel2.Font.Color:= clWhite; // color de texto
FLabel2.ShowAccelChar := False;
FLabel2.Caption := WizardForm.FinishedLabel.Caption;
FLabel2.Transparent := True;
FLabel2.Parent := WizardForm.FinishedPage;
end;
[Setup]
; --- Dispatching code ------------------------------------------------------------
[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := NextButtonClick1(CurPageID); if not Result then exit;
Result := NextButtonClick8(CurPageID); if not Result then exit;
end;
procedure InitializeWizard();
begin
InitializeWizard2();
InitializeWizard3();
InitializeWizard4();
InitializeWizard6();
InitializeWizard7();
InitializeWizard8();
end;
procedure DeinitializeSetup();
begin
DeinitializeSetup5();
end;
function InitializeSetup(): Boolean;
begin
Result := InitializeSetup5(); if not Result then exit;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
CurPageChanged7(CurPageID);
end;
function GetCustomSetupExitCode(): Integer;
begin
Result := GetCustomSetupExitCode8(); if Result>0 then exit;
end;
[Registry]
Root: HKCU; SubKey: {app}\XXXTeam; ValueType: string; ValueName: InstallPath;
Root: HKCU; SubKey: {app}\XXXTeam; ValueType: string; ValueName: Version;
[Ini]
Filename: "rev.ini"; Section: Emulator; Key: Language;
Filename: "rev.ini"; Section: steamclient; Key: PlayerName;
If you put the lines from the [Languages] section into a separate file (in this case the c:\Languages.txt), the following preprocessor script will generate the script that will add to the combo box placed on a custom page list of available languages and select the current one. On that custom page will also be the edit box for entering player's name. The name of the language along with the entered name will then be stored in the Setup.ini file into a selected application directory. The preprocessed script is saved as c:\PreprocessedScript.iss file.
Languages.txt content:
Note, that each item in the Languages.txt file must have the exact format:
the name and language file (path) must be enclosed by the "" chars
the file (path) must contain only one file (you cannot use delimited list of files)
Name: "default"; MessagesFile: "compiler:Default.isl"
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
Script file:
The ConvertLanguageName function is borrowed (and modified) from the InnoSetup source...
#define LanguageFile "c:\Languages.txt"
#define LanguageName
#define LanguageIndex
#define LanguageCount
#define FileLine
#define FileHandle
#dim LanguageList[65536]
#sub ProcessFileLine
#if FileLine != ""
#expr LanguageList[LanguageCount] = FileLine
#expr LanguageCount = ++LanguageCount
#endif
#endsub
#for {FileHandle = FileOpen(LanguageFile); \
FileHandle && !FileEof(FileHandle); \
FileLine = FileRead(FileHandle)} \
ProcessFileLine
#if FileHandle
#expr FileClose(FileHandle)
#endif
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Languages]
#sub AddLanguageItemSection
#emit LanguageList[LanguageIndex]
#endsub
#for {LanguageIndex = 0; LanguageIndex < LanguageCount; LanguageIndex++} AddLanguageItemSection
[INI]
Filename: "{app}\Setup.ini"; Section: "Emulator"; Key: "Language"; String: "{code:GetLanguageName}"; Flags: createkeyifdoesntexist
Filename: "{app}\Setup.ini"; Section: "SteamClient"; Key: "PlayerName"; String: "{code:GetPlayerName}"; Flags: createkeyifdoesntexist
[Code]
var
NameEdit: TNewEdit;
LanguageCombo: TNewComboBox;
LanguageNames: TStringList;
function ConvertLanguageName(const Value: string): string;
var
I: Integer;
WideCharCode: Word;
begin
Result := '';
I := 1;
while I <= Length(Value) do
begin
if Value[I] = '<' then
begin
WideCharCode := StrToInt('$' + Copy(Value, I + 1, 4));
I := I + 6;
end
else
begin
WideCharCode := Ord(Value[I]);
I := I + 1;
end;
SetLength(Result, Length(Result) + 1);
Result[Length(Result)] := Chr(WideCharCode);
end;
end;
function GetLanguageName(const Value: string): string;
begin
Result := LanguageNames[LanguageCombo.ItemIndex];
end;
function GetPlayerName(const Value: string): string;
begin
Result := NameEdit.Text;
end;
procedure InitializeWizard;
var
PlayerSettingsPage: TWizardPage;
NameLabel: TLabel;
LanguageLabel: TLabel;
begin
PlayerSettingsPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
NameLabel := TLabel.Create(WizardForm);
NameLabel.Parent := PlayerSettingsPage.Surface;
NameLabel.Left := 0;
NameLabel.Top := 0;
NameLabel.Caption := 'Name';
NameEdit := TNewEdit.Create(WizardForm);
NameEdit.Parent := PlayerSettingsPage.Surface;
NameEdit.Left := 0;
NameEdit.Top := NameLabel.Top + NameLabel.Height + 4;
NameEdit.Width := 250;
LanguageNames := TStringList.Create;
#sub AddLanguageInternalNames
#define GetLanguageInternalName(str S) \
Local[0] = Copy(S, Pos("Name:", S) + Len("Name:")), \
Local[1] = Copy(Local[0], Pos("""", Local[0]) + 1), \
Copy(Local[1], 1, Pos("""", Local[1]) - 1)
#emit ' LanguageNames.Add(''' + GetLanguageInternalName(LanguageList[LanguageIndex]) + ''');'
#endsub
#for {LanguageIndex = 0; LanguageIndex < LanguageCount; LanguageIndex++} AddLanguageInternalNames
LanguageLabel := TLabel.Create(WizardForm);
LanguageLabel.Parent := PlayerSettingsPage.Surface;
LanguageLabel.Left := 0;
LanguageLabel.Top := NameEdit.Top + NameEdit.Height + 8;
LanguageLabel.Caption := 'Language';
LanguageCombo := TNewComboBox.Create(WizardForm);
LanguageCombo.Parent := PlayerSettingsPage.Surface;
LanguageCombo.Left := 0;
LanguageCombo.Top := LanguageLabel.Top + LanguageLabel.Height + 4;
LanguageCombo.Width := NameEdit.Width;
LanguageCombo.Style := csDropDownList;
#sub AddLanguageDisplayNames
#define GetLanguageDisplayName(str S) \
ReadIni(S, "LangOptions", "LanguageName")
#define GetLanguageFile(str S) \
Local[0] = Copy(S, Pos("MessagesFile:", S) + Len("MessagesFile:")), \
Local[1] = Copy(Local[0], Pos("""", Local[0]) + 1), \
StringChange(Copy(Local[1], 1, Pos("""", Local[1]) - 1), "compiler:", CompilerPath)
#expr LanguageName = GetLanguageDisplayName(GetLanguageFile(LanguageList[LanguageIndex]))
#emit ' LanguageCombo.Items.Add(ConvertLanguageName(''' + LanguageName + '''));'
#endsub
#for {LanguageIndex = 0; LanguageIndex < LanguageCount; LanguageIndex++} AddLanguageDisplayNames
LanguageCombo.ItemIndex := LanguageNames.IndexOf(ActiveLanguage);
end;
procedure DeinitializeSetup;
begin
LanguageNames.Free;
end;
#expr SaveToFile("c:\PreprocessedScript.iss")
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