Danke das Findclose hat geholfen wie ein wunder
*danke*
Aber hier dennoch mal der code
Delphi-Quellcode:
procedure LV_InsertFiles(strPath: string; ListView: TlistView; ImageList: TImageList);
var
i: Integer;
SearchRec: TSearchRec;
ListItem: TListItem;
FileInfo: SHFILEINFO;
begin
ListView.Items.BeginUpdate;
try
i := FindFirst(strPath + '*.*', faAnyFile, SearchRec);
while i = 0 do
begin
with ListView do
begin
if ((SearchRec.Attr and FaDirectory <> FaDirectory) and
(SearchRec.Attr and FaVolumeId <> FaVolumeID)) then
begin
ListItem := ListView.Items.Add;
SHGetFileInfo(PChar(strPath + SearchRec.Name), 0, FileInfo, SizeOf(FileInfo), SHGFI_DISPLAYNAME);
Listitem.Caption := FileInfo.szDisplayName;
Application.ProcessMessages;
end;
end;
i := FindNext(SearchRec);
end;
finally
ListView.Items.EndUpdate;
Findclose(SearchRec); <---- nun eingefügt
end;
end;