onlyou13

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 function StrCmpLogicalW(psz1, psz2: PWideChar): Integer; stdcall; external 'shlwapi.dll';
 2 
 3 
 4 procedure GetFileList(list: TStringList; path: string; ext: string = '');
 5 var
 6   sr: TSearchRec;
 7   I, J, found: Integer;
 8   extStr: string;
 9 begin
10   list.Clear;
11   extStr := ext;
12 
13   if extStr = '' then
14     extStr := '*.*';
15   found := FindFirst(path + '\' + extStr, faAnyFile, sr);
16 
17   while found = 0 do
18   begin
19     if (sr.Name <> '.') and (sr.Name <> '..') and (sr.Attr <> faDirectory) then
20       list.Add(path + '\' + sr.Name);
21     found := FindNext(sr);
22   end;
23   FindClose(sr);
24 
25   for I := 0 to list.Count - 1 do
26   begin
27     for J := I + 1 to list.Count - 1 do
28     begin
29       if StrCmpLogicalW(PChar(list[I]), PChar(list[J])) > 0 then
30         list.Exchange(I, J);
31     end;
32   end;
33 end;

 

posted on 2021-01-13 11:34  onlyou13  阅读(272)  评论(0编辑  收藏  举报