FileForums

FileForums (https://fileforums.com/index.php)
-   Conversion Tutorials (https://fileforums.com/forumdisplay.php?f=55)
-   -   [HELP] List folders name | Inno Setup (https://fileforums.com/showthread.php?t=97223)

JRD! 27-09-2015 21:23

[HELP] List folders name | Inno Setup
 
I would like listed all folders contained in a directory.

I can only found the first folder name with this function:

Code:

[Setup]
AppName=Sample
AppVersion=1.0
DefaultDirName={pf}\Sample
DisableWelcomePage=true

[#Code]
function TryGetFirstSubfolder(const Path: string; out Folder: string): Boolean;
var
  S: string;
  FindRec: TFindRec;
begin
  Result := False;
  if FindFirst(ExpandConstant(AddBackslash(Path) + '*'), FindRec) then
  try
    repeat
      if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and
        (FindRec.Name <> '.') and (FindRec.Name <> '..') then
      begin
        Result := True;
        Folder := FindRec.Name;
        Exit;
      end;
    until
      not FindNext(FindRec);
  finally
    FindClose(FindRec);
  end;
end;

procedure InitializeWizard;
var
  CustomPage: TWizardPage;
  FileListBox: TNewListBox;
  S: string;
begin
  CustomPage := CreateCustomPage(wpWelcome, 'TryGetFirstSubfolder', 'Show the first folder name of C:');
  FileListBox := TNewListBox.Create(WizardForm);
  FileListBox.Parent := CustomPage.Surface;
  FileListBox.Align := alClient;
if TryGetFirstSubfolder('C:\', S) then FileListBox.Items.Add(S)
end;

How i could list all folders ?

Thank you.

peterf1999 28-09-2015 06:58

Code:

[Setup]
AppName=Sample
AppVersion=1.0
DefaultDirName={pf}\Sample
DisableWelcomePage=true

[*Code]

procedure TryGetFirstSubfolder(const Path: string; var FList: TNewListBox);
var
  S: string;
  FindRec: TFindRec;
 
begin
  if FindFirst(AddBackslash(Path) + '*', FindRec) then
  try
    repeat
      if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and
        (FindRec.Name <> '.') and (FindRec.Name <> '..') then
      begin
        FList.Items.Add(FindRec.Name);
      end;
    until
      not FindNext(FindRec);
  finally
    FindClose(FindRec);
  end;
end;

procedure InitializeWizard;
var
  CustomPage: TWizardPage;
  FileListBox: TNewListBox;
 
begin
  CustomPage := CreateCustomPage(wpWelcome, 'TryGetFirstSubfolder', 'Show the first folder name of C:');
  FileListBox := TNewListBox.Create(WizardForm);
  FileListBox.Parent := CustomPage.Surface;
  FileListBox.Align := alClient;
  TryGetFirstSubfolder('C:', FileListBox);
end;


JRD! 28-09-2015 07:37

Thanks peterf1999 !


All times are GMT -7. The time now is 20:33.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com