如何查找目录中的所有MP3文件?

dod*_*onl 3 delphi glob delphi-6

我最近开始使用delphi,现在我想从目录中获取所有mp3文件.我想要像php函数glob().

Bil*_*l99 12

旧的做法是:

var
  status : dword;
  sr : TSearchRec;
begin
  status := FindFirst('*.mp3',faAnyFile,sr);
  while status = 0 do
  begin

     // sr.Name is the filename; add it to a list
     // or something. Note there is no path so you
     // may need to add that back on somewhere

     status := FindNext(sr);
  end;
  SysUtils.FindClose(sr);

  // ...
end;
Run Code Online (Sandbox Code Playgroud)