Skip to content

Instantly share code, notes, and snippets.

@CitizenInsane
Created November 14, 2019 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CitizenInsane/f0f45308f08c95c4346a78ba358d9dac to your computer and use it in GitHub Desktop.
Save CitizenInsane/f0f45308f08c95c4346a78ba358d9dac to your computer and use it in GitHub Desktop.
; DEMO innosetup script to let user select macros to install
#define MyAppName "Choose custom files for install"
#define MyAppVersion "1.0"
#define MyAppPublisher "CitizenInsane"
#define MyAppURL "https://stackoverflow.com/questions/58840411/innosetup-choose-custom-files-to-install"
[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={{85C7F0EE-A37A-4650-B360-75628C8ACA2C}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir=deploy
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Dirs]
Name: {app}\macros
[Files]
Source: ".\macros\*.txt"; DestDir: "{app}\macros"; Flags: ignoreversion; AfterInstall: AfterInstallEachMacro;
[Code]
{* Global variables*}
var
GMacrosTotalCount : Integer;
GMacrosFullFilenames: TStringList;
GMacrosSelectectionPage : TInputOptionWizardPage;
{* On setup wizard initializing *}
procedure InitializeWizard();
begin
{* Init *}
GMacrosTotalCount := 0;
GMacrosFullFilenames := TStringList.Create();
GMacrosSelectectionPage := CreateInputOptionPage(wpInstalling, 'Macros', '', 'Select macros to install', false, true);
end;
{* On each new macro added *}
procedure AfterInstallEachMacro();
var
filename : String;
begin
filename := CurrentFileName;
filename := ExpandConstant(filename);
GMacrosFullFilenames.Add(filename);
filename := ExtractFileName(filename);
GMacrosSelectectionPage.Add(filename);
GMacrosSelectectionPage.Values[GMacrosTotalCount] := True;
GMacrosTotalCount := GMacrosTotalCount + 1;
end;
{* On clicking next button *}
function NextButtonClick(CurPageID: Integer): Boolean;
var index: Integer;
begin
Result := true;
{* When leaving page for macro selection *}
if (CurPageID = GMacrosSelectectionPage.ID) then begin
{* Delete macros the user do not want *}
for index := 0 to (GMacrosTotalCount - 1) do
begin
if (not(GMacrosSelectectionPage.Values[index])) then begin
DeleteFile(GMacrosFullFilenames[index]);
end;
end;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment