natürlich:
erstmal musst du eine globale varibale erstellen.
ich hab mal
var abort:boolean;
genommen.
um die procedure dann abzubrechen, musst du abort auf true setzten.
und hier die modifizierte version von getAllFilesInDirectory
Delphi-Quellcode:
procedure GetFilesInDirectory(ADirectory: string; AMask: String; AList: TStrings; ARekursiv: Boolean);
var
SR: TSearchRec;
begin
if (ADirectory<>'') and (ADirectory[length(ADirectory)]<>'\') then
ADirectory:=ADirectory+'\';
if (FindFirst(ADirectory+AMask,faAnyFile-faDirectory,SR)=0) then begin
repeat
if (SR.Name<>'.') and (SR.Name<>'..') and (SR.Attr<>faDirectory) then begin
AList.Add(ADirectory+SR.Name);
inc(count);
unit1.Form1.Label1.Caption:=IntToStr(count);
Application.ProcessMessages;
end;
if abort=true then exit; //<< Procedure beenden
until FindNext(SR)<>0;
FindClose(SR);
end;
if ARekursiv then
if (FindFirst(ADirectory+'*.*',faDirectory,SR)=0) then
begin
repeat
if (SR.Name<>'.') and (SR.Name<>'..') then begin
GetFilesInDirectory(ADirectory+SR.Name,AMask,AList,True);
inc(count);
unit1.Form1.Label1.Caption:=IntToStr(count);
Application.ProcessMessages;
end;
if abort=true then exit; //<< Procedure beenden
until FindNext(SR)<>0;
FindClose(SR);
end;
end;
und, funzt es?
tschö, kaemmi
Life is too short to hate people you never met before.