RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:9:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏
delphi - 获得文件属性
  • 作者:xiaoxiao
  • 发表时间:2020-12-23 11:01
  • 来源:未知

文件属性 - Attribute?

( from delphi help "FindFirst function" )The Attr parameter specifies the special files to include in addition to all normal files. Choose from these file attribute constants when specifying the Attr parameter:

--------------------------------------------------------------------------------

??? Constant?????? Description????? 数值??? 二进制??? faReadOnly???? Read-only files?? 1????? 1??? faHidden?????? Hidden files????? 2????? 10??? faSysFile????? System files????? 4????? 100??? faVolumeID???? Volume ID files?? 8????? 1000??? faDirectory??? Directory files?? 16???? 10000??? faArchive????? Archive files???? 32???? 100000??? faAnyFile????? Any file????????? 63???? 111111 (六位)?Attributes can be combined by adding (Delphi) or or-ing (C++) their constants or values. For example, to search for read-only and hidden files in addition to normal files, pass (faReadOnly + faHidden) in Delphi or (faReadOnly | faHidden) in C++ as the Attr parameter.?Attr 是整型,对应的整数值见上。采用这种形式的整数,从二进制就可以很清楚的看明白。分别用每一bit位来表示一种属性,faAnyFile对应的就是全1。?

但是在某些情况下,获得的Attr属性的值并不是上面所说的值。(XP系统,delphi7,NTFS压缩)而是如2064(100000 010000,目录),2080(100000 100000,Archive,文件,档案)之类的值。( 2048 + ? )可以发现变成了12位。后六位和上表中的意义是一致的。?

所以,要判断查找到的一个File是什么属性(Attribute),不能直接看其是否等于faArchive等,而是要取出后面的六位,然后再判断。??

--------------------------------------------------------------------------------

?现象:?下面是一些例子??? C盘(XP, NTFS,未压缩)下,.?????????????????? 16..????????????????? 16一般目录??????????? 16一般的文件????????? 32目录MATLAB6p5?????? 48 = 32 + 16 ??目录Program Files?? 17 = 16 + 1文件AUTOEXEC.BAT??? 2文件arcsetup.exe??? 39 = 1 + 2 + 4 +32文件boot.ini??????? 38 = 32 + 2 + 4文件iprpzi.hxo????? 34 = 32 + 2目录MSOCache??????? 19 = 1 + 2 + 16目录System Volume Information 8214 = 16 + 2 + 4 + 100000 00010110 B?????????????????????????????????? = 16 + 2 + 4 + 8192(2048*4)??? D盘(NTFS,压缩)下目录?????????????????? 2064 = 2048 + 16文件?????????????????? 2080 = 2048 + 32目录Recycler?????????? 2070 = 2048 + 22 = 2048 + 2 + 4 + 16目录System Volume Information???????? 22 = 2 + 4 + 16文件Thumbs.db????????? 2086 = 2 + 4 + 32 + 2048 文件TREEINFO.WC??????? 2050 = 2048 + 2?

?? H盘(Win2000,NTFS,未压缩)目录Program Files???????? 49 = 1 + 16 + 32目录WINNT???????????????? 48 = 16 + 32?