各位大虾帮帮忙,小D先谢过了! 怎样将一个磁盘中的所有文件及文件夹显示在一个ListView控件中,包括图标,即实现类似资源管理器中右边窗口的功能?请详细说明,最好有一段代码为例,我是菜鸟!分不是问题! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你看看Delphi提供的源代码!!! 看看 Samples中的ShellListView控件,应该可以满足你的要求。 转: 查找所有文件 procedure findall(disk,path: String; var fileresult: Tstrings); varfpath: String;fs: TsearchRec;beginfpath:=disk+path+'\*.*';if findfirst(fpath,faAnyFile,fs)=0 thenbeginif (fs.Name<>'.')and(fs.Name<>'..') thenif (fs.Attr and faDirectory)=faDirectory thenfindall(disk,path+'\'+fs.Name,fileresult)elsefileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');while findnext(fs)=0 dobeginif (fs.Name<>'.')and(fs.Name<>'..') thenif (fs.Attr and faDirectory)=faDirectory thenfindall(disk,path+'\'+fs.Name,fileresult)elsefileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');end;end;findclose(fs);end;procedure DoSearchFile(Path: string; Files: TStrings = nil);varInfo: TSearchRec;procedure ProcessAFile(FileName: string);beginif Assigned(PnlPanel) thenPnlPanel.Caption := FileName;Label2.Caption := FileName;end;function IsDir: Boolean;beginwith Info doResult := (Name <> '.') and (Name <> '..') and ((attr and fadirectory) = fadirectory);end;function IsFile: Boolean;beginResult := not ((Info.Attr and faDirectory) = faDirectory);end;beginPath := IncludeTrailingBackslash(Path);tryif FindFirst(Path + '*.*', faAnyFile, Info) = 0 thenif IsFile thenProcessAFile(Path + Info.Name)else if IsDir then DoSearchFile(Path + Info.Name);while FindNext(Info) = 0 dobeginif IsDir thenDoSearchFile(Path + Info.Name)else if IsFile thenProcessAFile(Path + Info.Name);Application.ProcessMessages;if QuitFlag then Break;Sleep(100);end;finallyFindClose(Info);end;end; 在面板的Samples页有个 ShellListView 组件非常适合你还有相关的ShellTreeView、ShellComboBox组件使用起来非常方便和简单 不好意思,我用的是D5!Samples页面没有你们所说的控件,!谢谢各位了! ShellTreeView、ShellComboBox这两个组件在D5里面可以用吗?如果可以,这两个控件在何处可以下载到? delphi5 中没有吗?那就用delphi6 或者在win31页里用filelistbox,directorylistbox,drivecombobox组合使用,也应该可以达到你想要的结果的。 继续前年的问题,如果做到跟WPE一样,发送游戏封包?(结贴100%) 事务操作问题 提示错误“对象关闭时,不允许操作”。 请问。大家都用什么delphi开发平台? 一个网络问题,达人进来看看 为什么捕获不到这个异常呢? fast report 使用哪个函树 可以求这一列的和啊 表无主键,只好通过记录号获取记录,如何通过记录号获取记录呢? 如何控制音量的大小 在DELPHI中用什么函数得到光盘的卷标? 如何汉化messagedlg中的按钮? 急用,关于ping,在线等 一个奇怪的问题,请高手来看一下。。。。
procedure findall(disk,path: String; var fileresult: Tstrings);
varfpath: String;fs: TsearchRec;beginfpath:=disk+path+'\*.*';if findfirst(fpath,faAnyFile,fs)=0 thenbeginif (fs.Name<>'.')and(fs.Name<>'..') thenif (fs.Attr and faDirectory)=faDirectory thenfindall(disk,path+'\'+fs.Name,fileresult)elsefileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');while findnext(fs)=0 dobeginif (fs.Name<>'.')and(fs.Name<>'..') thenif (fs.Attr and faDirectory)=faDirectory thenfindall(disk,path+'\'+fs.Name,fileresult)elsefileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');end;end;findclose(fs);end;procedure DoSearchFile(Path: string; Files: TStrings = nil);varInfo: TSearchRec;procedure ProcessAFile(FileName: string);beginif Assigned(PnlPanel) thenPnlPanel.Caption := FileName;Label2.Caption := FileName;end;function IsDir: Boolean;beginwith Info doResult := (Name <> '.') and (Name <> '..') and ((attr and fadirectory) = fadirectory);end;function IsFile: Boolean;beginResult := not ((Info.Attr and faDirectory) = faDirectory);end;beginPath := IncludeTrailingBackslash(Path);tryif FindFirst(Path + '*.*', faAnyFile, Info) = 0 thenif IsFile thenProcessAFile(Path + Info.Name)else if IsDir then DoSearchFile(Path + Info.Name);while FindNext(Info) = 0 dobeginif IsDir thenDoSearchFile(Path + Info.Name)else if IsFile thenProcessAFile(Path + Info.Name);Application.ProcessMessages;if QuitFlag then Break;Sleep(100);end;finallyFindClose(Info);end;end;
有个 ShellListView 组件非常适合你
还有相关的
ShellTreeView、ShellComboBox组件使用起来非常方便和简单
!
谢谢各位了!