怎样将一个磁盘中的所有文件及文件夹显示在一个ListView控件中,包括图标,即实现类似资源管理器中右边窗口的功能?
请详细说明,最好有一段代码为例,我是菜鸟!分不是问题!

解决方案 »

  1.   

    你看看Delphi提供的源代码!!!
      

  2.   

    看看 Samples中的ShellListView控件,应该可以满足你的要求。
      

  3.   

    转: 查找所有文件    
      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; 
     
      

  4.   

    在面板的Samples页
    有个 ShellListView 组件非常适合你
    还有相关的
    ShellTreeView、ShellComboBox组件使用起来非常方便和简单
      

  5.   

    不好意思,我用的是D5!Samples页面没有你们所说的控件,
    !
    谢谢各位了!
      

  6.   

    ShellTreeView、ShellComboBox这两个组件在D5里面可以用吗?如果可以,这两个控件在何处可以下载到?
      

  7.   

    delphi5 中没有吗?那就用delphi6 或者在win31页里用filelistbox,directorylistbox,drivecombobox组合使用,也应该可以达到你想要的结果的。