procedure TForm1.Button1Click(Sender: TObject);
var
SearchRec : TSearchRec;
Path : String;
Attr : integer;
Found : integer;
begin
Path := 'c:\*.*';//設定要顯示的路徑
Attr := faAnyFile;
Found := FindFirst(Path, Attr, SearchRec);//查找文件
while Found = 0 do
begin
ListVIEw1.Items.Add; //添加內容
ListView1.Items[ListVIEw1.Items.Count-1].Caption := (SearchRec.Name);
Found := FindNext(SearchRec);
end;
FindClose(SearchRec);//停止查找
end;