窗体name为main,上面放一个memo,Apath为目录路径,例如:'c:/
procedure TMain.SetListview(apath:string);
var
FSearchRec,DSearchRec:TSearchRec;
FindResult:integer;
f:file of byte;
Newitem:TListItem;
begin
findresult:=findfirst(Apath+'*.*',faanyfile,fsearchrec);
memo1.Items.Clear;
try
while findresult=0 do
begin
memo1.lines.add(fsearchrec.Name);
assignfile(f,Apath+fsearchrec.Name);
Reset(f);
closefile(f);
findresult:=findnext(fsearchrec)
end;
findresult:=findfirst(apath+'*.*',fadirectory,dsearchrec);
while findresult=0 do
findresult:=findnext(dsearchrec);
finally
findclose(fsearchrec);
end;
end;