用什么函数能获得指定目录下的目录列表?在先等。

ihez 2003-06-18 02:56:42
注意,是目录,不是文件名。谢谢!!
...全文
40 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ihez 2003-06-18
  • 打赏
  • 举报
回复
多谢各位!!!
l_xiaofeng 2003-06-18
  • 打赏
  • 举报
回复
使用FindFirst
DWGZ 2003-06-18
  • 打赏
  • 举报
回复
procedure DirList(const dir: string): string;
var SearchRec: TSearchRec; ok: integer; attrs: string[5];
begin
ok:=FindFirst(dir+'*',$3f,SearchRec);
while ok=0 do begin
with SearchRec do begin
if Attr and faDirectory <> 0 then attrs[1]:='D' else attrs[1]:='-';
if Attr and faArchive <> 0 then attrs[2]:='A' else attrs[2]:='-';
if Attr and faSysFile <> 0 then attrs[3]:='S' else attrs[3]:='-';
if Attr and faHidden <> 0 then attrs[4]:='H' else attrs[4]:='-';
if Attr and faReadOnly <> 0 then attrs[5]:='R' else attrs[5]:='-';
setlength(attrs,5);
writeln(attrs+' '+DateTimeToStr(FileDateToDateTime(time))+#9+IntToStr(size)+#9+dir+Name);
if Attr and faDirectory <> 0 then DirList(dir+Name+'\');
end;
ok:=FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
lion_lh 2003-06-18
  • 打赏
  • 举报
回复
var
iFindResult: integer;
SearchRec: TSearchRec;
begin
iFindResult := FindFirst('c:\*.*', faAnyFile, SearchRec);
while iFindResult = 0 do
begin
if SearchRec.Attr =faDirectory then
ListBox1.Items.Add(SearchRec.Name);
iFindResult := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
ihez 2003-06-18
  • 打赏
  • 举报
回复
DX,help!!!!!!!!

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧