Inno Setup - Create a dynamic list of components/types from external source (file or folder contents)

CADuser

I have a batch file (setting changer) that uses xcopy to list specific files formats in a specific folder, then allows me to type in one of the names and the script uses that name to copy that file to another location.

First xcopy creates a copy of the original as a backup (rolling backup only 1 copy) then does the file copy (extension is fixed in batch only body of filename needed This works great BUT I would love to try and do this in Inno Setup for a nice clean GUI.

I would like to populate the list of components/types from this list of files found in a specific fixed folder. Or even create an ini file with those names in (extra step but maybe better control). Main problem that might prevent this from being possible is not knowing how many entries it would be an array. If only 1 entry or file only 1 option (1 or a) if 4 then user can select 1 of 4 (a, b, c or d). I would extract the file name to create the name/description.

then on completion the same task as my batch would happen, backup (easy always the same name like start.ini) then copy the file e.g. example1.ini and overwrite start.ini

ini might be most flexible as I can imagine later adding new sections to change the actions performed.

Is this possible or stretching this program too far. No rush as my batch works for now but the less typing and manual steps the better for continued use.

I found an example to list contents to a dialog window but I could not figure how to use this to populate components. TLama - List all files in a directory

Martin Prikryl

You cannot create the components dynamically on runtime (you can on compile-time).


But it's not difficult to implement a custom dynamic components-like page using the CreateCustomPage and the TNewCheckListBox.

Then in the CurStepChanged(ssInstall) you process the selected files/components as your need.

Dynamic components list

[Code]

const
  SourcePath = 'C:\somepath';

var
  CustomSelectTasksPage: TWizardPage;
  ComponentsList: TNewCheckListBox;

procedure InitializeWizard();
var
  FindRec: TFindRec;
  SelectComponentsLabel: TNewStaticText;
begin
  CustomSelectTasksPage :=
    CreateCustomPage(
      wpSelectComponents, SetupMessage(msgWizardSelectComponents),
      SetupMessage(msgSelectComponentsDesc));

  SelectComponentsLabel := TNewStaticText.Create(WizardForm);
  SelectComponentsLabel.Parent := CustomSelectTasksPage.Surface;
  SelectComponentsLabel.Top := 0;
  SelectComponentsLabel.Left := 0;
  SelectComponentsLabel.Width := CustomSelectTasksPage.Surface.Width;
  SelectComponentsLabel.AutoSize := False;
  SelectComponentsLabel.ShowAccelChar := False;
  SelectComponentsLabel.WordWrap := True;
  SelectComponentsLabel.Caption := SetupMessage(msgSelectComponentsLabel2);
  WizardForm.AdjustLabelHeight(SelectComponentsLabel);

  ComponentsList := TNewCheckListBox.Create(WizardForm);
  ComponentsList.Parent := CustomSelectTasksPage.Surface;
  ComponentsList.Top :=
    SelectComponentsLabel.Top + SelectComponentsLabel.Height + ScaleY(8);
  ComponentsList.Left := 0;
  ComponentsList.Width := CustomSelectTasksPage.Surface.Width;
  ComponentsList.Height := CustomSelectTasksPage.Surface.Height - ComponentsList.Top;

  if FindFirst(ExpandConstant(AddBackslash(SourcePath) + '*.dat'), FindRec) then
  begin
    try
      repeat
        ComponentsList.AddCheckBox(FindRec.Name, '', 0, False, True, False, False, nil);
      until not FindNext(FindRec);
    finally
      FindClose(FindRec);
    end;
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  I: Integer;
  FileName: string;
  SourceFilePath: string;
  TargetFilePath: string;
begin
  if CurStep = ssInstall then
  begin
    for I := 0 to ComponentsList.Items.Count - 1 do
    begin
      if ComponentsList.Checked[I] then
      begin
        FileName := ComponentsList.Items[I];
        SourceFilePath := AddBackslash(SourcePath) + FileName;
        TargetFilePath := AddBackslash(ExpandConstant('{app}')) + FileName;
        if FileCopy(SourceFilePath, TargetFilePath, False) then
        begin
          Log(Format('Installed "%s".', [FileName]));
        end
          else
        begin
          Log(Format('Failed to install "%s".', [FileName]));
        end;
      end;
    end;
  end;
end;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Install external file from subdirectory (relative path) using Inno Setup

From Dev

Install external file from subdirectory (relative path) using Inno Setup

From Dev

How to create a zip file from contents of a folder with certain name pattern?

From Dev

Inno Setup Code section create hidden file

From Dev

.bat - Create a menu from folder file list

From Dev

Inno Setup: List all file names in an directory

From Dev

Inno Setup create TStringList from CDATA

From Dev

Create ZIP files from within Inno Setup

From Dev

Inno Setup: Get 'Don't create a start menu folder' option

From Dev

Inno Setup: Get 'Don't create a start menu folder' option

From Dev

Dynamic password in Inno Setup

From Dev

Inno Setup unzip file from input user

From Dev

Create file/folder list

From Dev

Inno-setup pack all files in a folder exept for 1 file

From Dev

Inno-setup pack all files in a folder exept for 1 file

From Dev

Checking existence of a file in Inno Setup Internal Temporary folder

From Dev

Automatically Create text file of folder contents

From Dev

Create a hardlink with Inno Setup

From Dev

How to create a scrollable radio button list in Inno Setup?

From Dev

What happens in Inno Setup when you list the same file twice?

From Dev

Inno Setup create array from comma delimited strings stored in an array

From Dev

Windows cmd batch file, copy source folder and contents

From Dev

Windows cmd batch file, copy source folder and contents

From Dev

How to install only file based on condition (external configuration file) in Inno Setup

From Dev

Inno Setup: Reading a file from installer during uninstallation

From Dev

LoadStringFromFile and StringChangeEx from Unicode Inno Setup (Ansi file)

From Dev

Read bytes from file at desired position with Inno Setup

From Dev

Inno Setup: Delete empty lines from test file

From Dev

LoadStringFromFile and StringChangeEx from Unicode Inno Setup (Ansi file)

Related Related

  1. 1

    Install external file from subdirectory (relative path) using Inno Setup

  2. 2

    Install external file from subdirectory (relative path) using Inno Setup

  3. 3

    How to create a zip file from contents of a folder with certain name pattern?

  4. 4

    Inno Setup Code section create hidden file

  5. 5

    .bat - Create a menu from folder file list

  6. 6

    Inno Setup: List all file names in an directory

  7. 7

    Inno Setup create TStringList from CDATA

  8. 8

    Create ZIP files from within Inno Setup

  9. 9

    Inno Setup: Get 'Don't create a start menu folder' option

  10. 10

    Inno Setup: Get 'Don't create a start menu folder' option

  11. 11

    Dynamic password in Inno Setup

  12. 12

    Inno Setup unzip file from input user

  13. 13

    Create file/folder list

  14. 14

    Inno-setup pack all files in a folder exept for 1 file

  15. 15

    Inno-setup pack all files in a folder exept for 1 file

  16. 16

    Checking existence of a file in Inno Setup Internal Temporary folder

  17. 17

    Automatically Create text file of folder contents

  18. 18

    Create a hardlink with Inno Setup

  19. 19

    How to create a scrollable radio button list in Inno Setup?

  20. 20

    What happens in Inno Setup when you list the same file twice?

  21. 21

    Inno Setup create array from comma delimited strings stored in an array

  22. 22

    Windows cmd batch file, copy source folder and contents

  23. 23

    Windows cmd batch file, copy source folder and contents

  24. 24

    How to install only file based on condition (external configuration file) in Inno Setup

  25. 25

    Inno Setup: Reading a file from installer during uninstallation

  26. 26

    LoadStringFromFile and StringChangeEx from Unicode Inno Setup (Ansi file)

  27. 27

    Read bytes from file at desired position with Inno Setup

  28. 28

    Inno Setup: Delete empty lines from test file

  29. 29

    LoadStringFromFile and StringChangeEx from Unicode Inno Setup (Ansi file)

HotTag

Archive