怎么才能在一个listview里面显示C盘根目录下的所有东东?包括文件夹、文件等等?最好有一个例子,效果就像打开C盘,在大图标方式下看到的一样。不知那位大侠有这样的东东,谢了先!

解决方案 »

  1.   

    用samples里面的控件 ShellListView
      

  2.   

    在ShellListView里面怎样禁止用户打开一个文件夹?也就是只能选择,不能通过双击进行打开?
      

  3.   

    也可以用ListView!先获得文件列表,用什么方法?FindFirst,FindNext,这种代码很容易写吧?
    不过我喜欢用FileListBox控件,然后...var
    PicFileSize,PFile,i:integer;
    FSize,FDateTime:String;
    LV:TListItem;
    begin
    For i:=1 to FileListBox.Items.Count do
    begin
      try
        if DirPath<>SV.Directory then Break;
        LV:=ListView.Items.Add;
        LV.Caption:=FileListBox.Items.Strings[i-1];
        LV.ImageIndex:=GetFileIcoIndex(FileListBox.Items.Strings[i-1]);
        Repeat
        PFile:=FileOpen(FileListBox.Items.Strings[i-1], fmOpenRead);
        until PFile<>-1;
        FDateTime:=DateTimeToStr(FileDateToDateTime(FileGetDate(PFile)));
        PicFileSize:=FileSeek(PFile,0,2);
        FileClose(PFile);
        if PicFileSize<1024 then
          FSize:=inttostr(PicFileSize)+' 字节'
        else if PicFileSize<1048576 then
          FSize:=floattostr(Trunc(PicFileSize/102.4)/10)+' KB'
        else
          FSize:=floattostr(Trunc(PicFileSize/104857.6)/10)+' MB';
        LV.SubItems.Add(FSize);
        LV.SubItems.Add(FDateTime);
      except
        Continue;
      end;
      Application.ProcessMessages;
    end;
    end;