View Single Post
  #1  
Old 27-09-2015, 21:23
JRD!'s Avatar
JRD! JRD! is offline
Registered User
 
Join Date: Sep 2015
Location: Matrix
Posts: 274
Thanks: 225
Thanked 600 Times in 168 Posts
JRD! is on a distinguished road
[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.
Reply With Quote
Sponsored Links