но SearchRec.size выдает какието несусветные размеры.
- Код: Выделить всё
// Список файлов
procedure ListViewFls(strPath: string; ListView: TListView; ImageList: TImageList);
var
i: Integer;
SearchRec: TSearchRec;
ListItem: TListItem;
attr : String[5];
begin
attr := '12345';
ListView.Items.BeginUpdate;
ListView.Items.Clear;
try
i := FindFirstUTF8(strPath + '*.*', faAnyFile, SearchRec); // search for the first file
while i = 0 do begin
with ListView do begin // On directories and volumes
if ((SearchRec.Name <> '.') and
(SearchRec.Attr and FaVolumeID <> FaVolumeID)) then begin
ListItem := ListView.Items.Add;
if (SearchRec.Attr and FaDirectory = FaDirectory) then
ListItem.ImageIndex := 0
else
ListItem.ImageIndex := 1;
ListItem.Caption := SearchRec.Name; //FileInfo.szDisplayName;
ListItem.SubItems.Add(inttostr(SearchRec.size div 1024));
ListItem.SubItems.Add(datetimetostr(FileDateToDateTime(SearchRec.time)));
if (SearchRec.Attr and FaDirectory = FaDirectory) then attr[1] := 'D' else attr[1] := '_';
if (SearchRec.Attr and FaArchive = FaArchive) then attr[2] := 'A' else attr[2] := '_';
if (SearchRec.Attr and FaHidden = FaHidden) then attr[3] := 'H' else attr[3] := '_';
if (SearchRec.Attr and FaReadOnly = FaReadOnly) then attr[4] := 'R' else attr[4] := '_';
if (SearchRec.Attr and FaSysFile = FaSysFile) then attr[5] := 'S' else attr[5] := '_';
ListItem.SubItems.Add(attr);
end;
end;
i := FindNextUTF8(SearchRec);
end;
FindCloseUTF8(SearchRec);
finally
ListView.Items.EndUpdate;
end;
end;
не могу найти причину. В Delphi все работает нормально.