Inno Setup Finding folder and using multiple choice of directories

John Turing

I have a big problem to solve which is if you have a directory ..\App which has two folders but you don't know the folders names:

C:\Program Files (x86)\App\EFRTJKD
C:\Program Files (x86)\App\UDSIDJF

How can Inno script help identify the EFRTJKD and UDSIDJF and show them as choices in the installation page? Instead of the Browse directory option?

The two folders both have a file named Program.exe and Version.txt. The Version.txt contains a description of the folder. I want to display the description in the folder selection.

Thank you very much. I really appreciate your help.

Martin Prikryl

Use FindFirst/FindNext to find your folders.

And then you can put them for example to TNewCheckListBox. Hide the DirEdit. And update its hidden contents based on what user selected in the TNewCheckListBox

[Code]

var
  DirCheckListBox: TNewCheckListBox;
  Dirs: TStringList;

procedure DirCheckListBoxClick(Sender: TObject);
begin
  { When user changes selection, update the path in hidden edit box }
  WizardForm.DirEdit.Text := Dirs[DirCheckListBox.ItemIndex];
end;

procedure InitializeWizard();
var
  FindRec: TFindRec;
  RootPath: string;
  Path: string;
  Name: AnsiString;
begin
  DirCheckListBox := TNewCheckListBox.Create(WizardForm);
  DirCheckListBox.Parent := WizardForm.DirEdit.Parent;
  DirCheckListBox.Top := WizardForm.SelectDirBrowseLabel.Top;
  DirCheckListBox.Left := WizardForm.DirEdit.Left;
  DirCheckListBox.Width := WizardForm.DirEdit.Width;
  DirCheckListBox.Height :=
    WizardForm.DiskSpaceLabel.Top - DirCheckListBox.Top - ScaleY(8);
  DirCheckListBox.Color := WizardForm.TasksList.Color;
  DirCheckListBox.WantTabs := WizardForm.TasksList.WantTabs;
  DirCheckListBox.MinItemHeight := WizardForm.TasksList.MinItemHeight;
  DirCheckListBox.ParentColor := WizardForm.TasksList.ParentColor;
  DirCheckListBox.BorderStyle := WizardForm.TasksList.BorderStyle;

  WizardForm.DirEdit.Visible := False;
  WizardForm.DirBrowseButton.Visible := False;
  WizardForm.SelectDirBrowseLabel.Visible := False;

  RootPath := ExpandConstant('{pf}\App');

  Dirs := TStringList.Create;

  if FindFirst(RootPath + '\*', FindRec) then
  begin
    repeat
      if ((FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0) and
         (FindRec.Name <> '.') and
         (FindRec.Name <> '..') then
      begin
        Path := RootPath + '\' + FindRec.Name;
        { LoadStringFromFile can handle only ascii/ansi files, no Unicode }
        if LoadStringFromFile(Path + '\' + 'version.txt', Name) then
        begin
          Dirs.Add(Path);
          DirCheckListBox.AddRadioButton(Name, '', 0, False, True, nil);
          { If already installed, check the path that was selected previously, }
          { otherwise check the first one }
          if (DirCheckListBox.Items.Count = 1) or
             (CompareText(WizardForm.DirEdit.Text, Path) = 0) then
          begin
            DirCheckListBox.ItemIndex := DirCheckListBox.Items.Count - 1;
            DirCheckListBox.Checked[DirCheckListBox.ItemIndex] := True;
          end;
        end;
      end;
    until not FindNext(FindRec);
  end;

  if DirCheckListBox.Items.Count = 0 then
  begin
    RaiseException('No folder found.');
  end;

  DirCheckListBox.OnClickCheck := @DirCheckListBoxClick;
  DirCheckListBoxClick(nil);
end;

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Signing files using Inno Setup with the signonce flag

From Dev

Using constants and code in procedure calls (inno setup)

From Dev

Inno Setup: pack folder with all subfolders

From Dev

Using AppMutex with silent Inno Setup

From Dev

How to support thousands of files using Inno Setup?

From Dev

How to delete a nonempty folder in inno setup

From Dev

Using custom DLL with Inno-Setup

From Dev

Inno Setup: Delete folder with Task function

From Dev

Write serial number to file using Inno Setup

From Dev

Using {AppVersion} as a parameter for a function in Inno Setup

From Dev

Inno Setup - Installer for multiple installers

From Dev

Inno Setup: access violation using IShellLink GetWorkingDirectory

From Dev

Create a small web installer using Inno Setup

From Dev

Microsoft SmartScreen - suspended using Inno Setup installer?

From Dev

Running netsh from using Inno Setup Exec()

From Dev

Inno Setup give user choice of which application to associate extensions with

From Dev

Inno Setup - How to set permissions of installation folder

From Dev

How to find an unique name to rename/archive old directories in Inno Setup

From Dev

Inno Setup - Get a path to parent folder

From Dev

Inno Setup - AfterInstall action executed multiple times

From Dev

Preventing Inno Setup from uninstalling empty directories created with createallsubdirs flag

From Dev

Creating shortcut in startup folder using Inno setup

From Dev

How to check Internet connection using Inno Setup

From Dev

Creating a windows installer for python using inno setup

From Dev

Inno Setup: Multiple Next Buttons

From Dev

Inno setup Arabic directories name error

From Dev

Inno Setup - Installer for multiple installers

From Dev

Copy Multiple Directories into One Directory Keeping the root folder using Robocopy

From Dev

Inno Setup shortcuts for folder are not opening in Windows 10

Related Related

  1. 1

    Signing files using Inno Setup with the signonce flag

  2. 2

    Using constants and code in procedure calls (inno setup)

  3. 3

    Inno Setup: pack folder with all subfolders

  4. 4

    Using AppMutex with silent Inno Setup

  5. 5

    How to support thousands of files using Inno Setup?

  6. 6

    How to delete a nonempty folder in inno setup

  7. 7

    Using custom DLL with Inno-Setup

  8. 8

    Inno Setup: Delete folder with Task function

  9. 9

    Write serial number to file using Inno Setup

  10. 10

    Using {AppVersion} as a parameter for a function in Inno Setup

  11. 11

    Inno Setup - Installer for multiple installers

  12. 12

    Inno Setup: access violation using IShellLink GetWorkingDirectory

  13. 13

    Create a small web installer using Inno Setup

  14. 14

    Microsoft SmartScreen - suspended using Inno Setup installer?

  15. 15

    Running netsh from using Inno Setup Exec()

  16. 16

    Inno Setup give user choice of which application to associate extensions with

  17. 17

    Inno Setup - How to set permissions of installation folder

  18. 18

    How to find an unique name to rename/archive old directories in Inno Setup

  19. 19

    Inno Setup - Get a path to parent folder

  20. 20

    Inno Setup - AfterInstall action executed multiple times

  21. 21

    Preventing Inno Setup from uninstalling empty directories created with createallsubdirs flag

  22. 22

    Creating shortcut in startup folder using Inno setup

  23. 23

    How to check Internet connection using Inno Setup

  24. 24

    Creating a windows installer for python using inno setup

  25. 25

    Inno Setup: Multiple Next Buttons

  26. 26

    Inno setup Arabic directories name error

  27. 27

    Inno Setup - Installer for multiple installers

  28. 28

    Copy Multiple Directories into One Directory Keeping the root folder using Robocopy

  29. 29

    Inno Setup shortcuts for folder are not opening in Windows 10

HotTag

Archive