怎样才能取出我所读文件的文件名和它的相关属性?(我查不到相关的帖子啊!)(50分)

  • 主题发起人 主题发起人 DELPHI鸟
  • 开始时间 开始时间
D

DELPHI鸟

Unregistered / Unconfirmed
GUEST, unregistred user!
我从一个文件夹里读一个文件,怎样才能取出我所读文件的文件名和它的相关属性?
例如文件名、创建时间、修改、访问时间。
问题很急。先谢谢大家了
 
uses shellapi; //that unit is necessary

procedure getshellinfo(a:tfilename;var name,typ:string;var icon:ticon;var attr:integer);
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;

 
来晚了。
给你个帮助:
C:/Program Files/Common Files/Borland Shared/MSHelp/win32s.hlp
 
多人接受答案了。
 
后退
顶部