procedure
TForm1
.
FormCreate(Sender: TObject);
var
WFD:WIN32_Find_Data;
HFile:THandle;
Attr,Path:
String
;
begin
ListView1
.
Items
.
BeginUpdate;
ListView1
.
Items
.
Clear;
Path:=IncludeTrailingPathDelimiter(
'C:\Windows'
);
HFile:=FindFirstFile(
PChar
(Path+
'*.*'
),WFD);
if
HFile<>INVALID_HANDLE_VALUE
then
begin
repeat
if
(WFD
.
dwFileAttributes
and
faHidden)<>
2
then
if
StrPas(WFD
.
cFileName)<>
'.'
then
with
ListView1
.
Items
.
Add
do
begin
if
(WFD
.
dwFileAttributes
and
faDirectory)<>faDirectory
then
begin
Caption:=WFD
.
cFileName;
SubItems
.
Add(ExtractFileExt(WFD
.
cFileName));
SubItems
.
Add(
'размер'
);
end
else
begin
Caption:=(WFD
.
cFileName);
SubItems
.
Add(
'[Папка]'
);
SubItems
.
Add(
'размер'
);
end
;
SubItems
.
Add(
'Дата'
);
Attr:=
'----'
;
if
(WFD
.
dwFileAttributes
and
faArchive)<>
0
then
Attr[
1
]:=
'a'
;
if
(WFD
.
dwFileAttributes
and
faReadOnly)<>
0
then
Attr[
2
]:=
'r'
;
if
(WFD
.
dwFileAttributes
and
faHidden)<>
0
then
Attr[
3
]:=
'h'
;
if
(WFD
.
dwFileAttributes
and
faSysFile)<>
0
then
Attr[
4
]:=
's'
;
SubItems
.
Add(Attr);
end
;
application
.
ProcessMessages;
until
FindNextFile(HFile,WFD)<>
True
;
Winapi
.
Windows
.
FindClose(HFile);
end
;
ListView1
.
Items
.
EndUpdate;
end
;