Registriert seit: 23. Aug 2005
Ort: Homburg
274 Beiträge
Delphi 7 Professional
|
Re: Listbox Leeren
2. Sep 2005, 08:21
[i]vorher
Delphi-Quellcode:
function FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean
= True): TStinDynA;
var
//--Funktionsvariablen---------------------------------------------------------------------
Wn32FiDa: TWin32FindData;
File0001: THandle;
begin
if AnsiLastChar(RootFolder) <> '\' then
begin
RootFolder := RootFolder + '\';
end;
if Recurse then
begin{if-1}
File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
if File0001 <> INVALID_HANDLE_VALUE then
try {try(if-2)}
repeat
if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=FILE_ATTRIBUTE_DIRECTORY then
begin
if (string(Wn32FiDa.cFileName) <> '.') and (string(Wn32FiDa.cFileName) <> '..')then
begin
FindAllFiles(RootFolder + Wn32FiDa.cFileName, Mask, Recurse);
end;
end;
until FindNextFile(File0001, Wn32FiDa) = False;
finally
windows.FindClose(File0001);
end;{try(if-2)}
end;{if 1}
File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
if File0001 <> INVALID_HANDLE_VALUE then
try {try(if-4)}
repeat
if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <>
FILE_ATTRIBUTE_DIRECTORY then
begin
gFileCont := length(gFile0001)+1;
Setlength(gFile0001, gFileCont);
gFile0001[gFileCont - 1] := RootFolder + String(Wn32FiDa.cFileName);
end;{if-3}
until FindNextFile(File0001, Wn32FiDa) = False;
finally
Windows.FindClose(File0001);
end;{try(if-4)}
end;{Funktion}
Nachher
Delphi-Quellcode:
function FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean
= True): TStinDynA;
var
//--Funktionsvariablen---------------------------------------------------------------------
Wn32FiDa: TWin32FindData;
File0001: THandle;
begin
SetLength(gFile0001, 0); //<= das hab ich eingefügt!!
if AnsiLastChar(RootFolder) <> '\' then
begin
RootFolder := RootFolder + '\';
end;
if Recurse then
begin{if-1}
File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
if File0001 <> INVALID_HANDLE_VALUE then
try {try(if-2)}
repeat
if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=FILE_ATTRIBUTE_DIRECTORY then
begin
if (string(Wn32FiDa.cFileName) <> '.') and (string(Wn32FiDa.cFileName) <> '..')then
begin
FindAllFiles(RootFolder + Wn32FiDa.cFileName, Mask, Recurse);
end;
end;
until FindNextFile(File0001, Wn32FiDa) = False;
finally
windows.FindClose(File0001);
end;{try(if-2)}
end;{if 1}
File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
if File0001 <> INVALID_HANDLE_VALUE then
try {try(if-4)}
repeat
if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <>
FILE_ATTRIBUTE_DIRECTORY then
begin
gFileCont := length(gFile0001)+1;
Setlength(gFile0001, gFileCont);
gFile0001[gFileCont - 1] := RootFolder + String(Wn32FiDa.cFileName);
end;{if-3}
until FindNextFile(File0001, Wn32FiDa) = False;
finally
Windows.FindClose(File0001);
end;{try(if-4)}
end;{Funktion}
Johannes
|
|
Zitat
|