得到指定目录中所有文件的信息(文件名、时间、大小、属性),并在listView中显示?(listView的viewStyle为vsReport)
解决方案 »
- 请问TIDFTP控件有时候死程序怎么办?
- 如何进行批量更新数据?急
- 怎么取到另一程序弹出消息框中的提示信息的文本?
- 急!急!急!ADODataSet中有SaveToFile方法,但如果不想直接保存到文件中,而要直接保存到数据流中行不行?
- 如何即时刷新:关于ADOQuery、DBGrid、DataSource
- fr2.5报表为何不能预览?
- ~~~~~~~对利用Midas机质做N层结构疑惑!?~~~~~~~
- case语句的表达式中如何用实型进行判断?
- 高手请帮忙:delphi 如何连接sybase sql anywhere5.0数据库
- socket入门
- 哪位高人知道?
- 求助:只有一字段,多列报表用哪个控件实现较好?
var
info : tshfileinfo;
begin
// get shell-info about the specified file (in "a")
{parameters :
name : receives the explorer-style filename (e.g. without extension)
typ : receives the explorer-style typename of the file (e.g. "anwendung" for an exe in german win95)
icon : will content the icon which is shown in the explorer for that file (this is slower than extracticon !!!!)
attr : gets the explorer-attributes of the file, these are (ripped from win32-help):
sfgao_cancopy the specified file objects or folders can be copied (same value as the dropeffect_copy flag).
sfgao_candelete the specified file objects or folders can be deleted.
sfgao_canlink it is possible to create shortcuts for the specified file objects or folders (same value as the dropeffect_link flag).
sfgao_canmove the specified file objects or folders can be moved (same value as the dropeffect_move flag).
sfgao_canrename the specified file objects or folders can be renamed.
sfgao_capabilitymask mask for the capability flags.
sfgao_droptarget the specified file objects or folders are drop targets.
sfgao_haspropsheet the specified file objects or folders have property sheets. a file object's display attributes may include zero or more of the following values: sfgao_displayattrmask mask for the display attributes.
sfgao_ghosted the specified file objects or folders should be displayed using a ghosted icon.
sfgao_link the specified file objects are shortcuts.
sfgao_readonly the specified file objects or folders are read-only.
sfgao_share the specified folders are shared. a file object's contents flags may include zero or more of the following values: sfgao_contentsmask mask for the contents attributes.
sfgao_hassubfolder the specified folders have subfolders (and are, therefore, expandable in the left pane of windows explorer). a file object may have zero or more of the following miscellaneous attributes: sfgao_filesystem the specified folders or file objects are part of the file system (that is, they are files, directories, or root directories).
sfgao_filesysancestor the specified folders contain one or more file system folders.
sfgao_folder the specified items are folders.
sfgao_removable the specified file objects or folders are on removable media.
sfgao_validate validate cached information.}
fillchar(info,sizeof(tshfileinfo),0);
shgetfileinfo(pchar(a),0,info,sizeof(info),shgfi_displayname or shgfi_typename or
shgfi_icon or shgfi_attributes);
with info do begin
name := szdisplayname;
typ := sztypename;
icon.handle := hicon;
attr := dwattributes;
end;
end;
//PathName:所读取的目录名称 如 c:\test
//FileType:所读取的文件类型 如 *.* A2003??.*等等
//Rslist:读取返回的Stringlist调用时事先定义一个变量为TStringlist类型
var
Example:Tstringlist;调用时:
GetFilesName('c:\test','*.txt',Example);//子程序如下:
//
procedure GetFilesName(PathName:string;FileType:string;var
RsList:Tstringlist);
var
SearchFile:TSearchRec;
Succeed:boolean;
begin
RsList.Free;
RsList:=Tstringlist.Create;
Succeed:=True;
if (not DirectoryExists(PathName)) or
(not FindFirst(PathName+FileType,faAnyFile,Searchfile)=0)
then Succeed:=False;
if Succeed then
begin
RsList.Append(PathName+'\'+Trim(SearchFile.Name));
while FindNext(Searchfile) =0 do
RsList.Append(PathName+'\'+Trim(SearchFile.Name));
FindClose(SearchFile);
end
else
begin
RsList.Append('No Files!');
FindClose(SearchFile);
end;
end;