Ja, ist es. Aber ich habe es jetzt mit der der Pointer als Parameter-Version gemacht:
Delphi-Quellcode:
procedure TForm1.FindAllFiles3(AlreadyFound: TListOfStrings; RootFolder: string; Mask: string = '*.*'; Recurse: Boolean = True);
var
SR: TSearchRec;
begin
if AnsiLastChar(RootFolder)^ <> '\' then
RootFolder := RootFolder + '\';
if FindFirst(RootFolder + Mask, faAnyFile, SR) = 0 then
try
repeat
if (SR.Name <> '.') and (SR.Name <> '..') then
begin
AlreadyFound.AddString(RootFolder + SR.Name);
if (SR.Attr and faDirectory = faDirectory) then
FindAllFiles3(AlreadyFound, RootFolder + SR.Name, Mask, Recurse);
end;
until
FindNext(SR) <> 0;
finally
FindClose(SR);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
tk: cardinal;
LoS: tListOfStrings;
count: cardinal;
MaxTimes: cardinal;
FolderName: string;
begin
tk := GetTickCount;
FolderName := Edit1.Text;
MaxTimes := 3;
for count := 0 to MaxTimes do
begin
LoS := TListOfStrings.Create(100);
if AnsiLastChar(FolderName)^ = '\' then
FolderName := copy(FolderName, 0, pred(length(FolderName))); //damit alles ohne '\' in der Liste steht
//noch ein check, ob der String gültig ist
LoS.AddString(FolderName);
if FileGetAttr(FolderName) and faDirectory = faDirectory then
FindAllFiles3(LoS, FolderName);
LoS.TruncateArray;
Caption := inttostr(LoS.GetLength);
Form1.Update;
LoS.Free;
end;
Caption := Caption + ' ' + inttostr(GetTickCount - tk);
end;
Das funktioniert soweit auch.