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.
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;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments