FindFirst() 报告的奇怪属性值,Attr = 2080
当使用 FindFirst() 搜索文件时,我在 TSearchRec.Attr 字段中得到一个属性值 2080。它在帮助中没有指定,因为只有这些值可用,并且它们的组合不会产生 2080:
1 faReadOnly
2 fa隐藏
4 faSys文件
8 faVolumeID
16 fa目录
32 fa档案
64 faSymLink
71 faAnyFile
有谁知道 2080 是什么意思以及为什么我得到该属性值?操作系统是XP嵌入式的。
When searching for files with FindFirst() I get an attribute value in the TSearchRec.Attr field of 2080. It is not specified in the help as there are only these values available and no combination of them yields 2080:
1 faReadOnly
2 faHidden
4 faSysFile
8 faVolumeID
16 faDirectory
32 faArchive
64 faSymLink
71 faAnyFile
Does anyone know what 2080 means and why I get that attribute value? The OS is XP embedded.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
事实证明,FindFirst() 找到的文件已被压缩,因此设置了压缩位。我花了一段时间才弄清楚,我在网上找不到说明设置压缩位时 TSearchRec.Attr 的实际值的参考。取消单击文件高级属性中的“压缩文件”就可以了。
It turns out that the file found by FindFirst() was compressed and thus had the compressed bit set. Took me a while to figure out and I could not find a reference on the web that stated the actual value of TSearchRec.Attr when the compressed bit is set. Unclicking "Compress file" in the files advanced properties did the trick.
TSearchRec
中的属性直接映射到 Windows 文件属性 与TWin32FindData
记录来自FindFirstFile
。在十六进制中(始终以十六进制呈现位字段,而不是十进制),2080 是 $0820,很明显设置了两个位。低位对应于
File_Attribute_Archive
,或者Delphi的faArchive< /code>
,高位对应
File_Attribute_Compressed
。它在 Delphi 附带的单元中没有等效项,但您可以使用JclFileUtils.faCompressed
来自 JCL 的符号。Attributes in
TSearchRec
map directly to the Windows file attributes used with theTWin32FindData
record fromFindFirstFile
.In hex (always render bit fields in hex, not decimal), 2080 is $0820, where it's clear there are two bits set. The lower bit corresponds to
File_Attribute_Archive
, or Delphi'sfaArchive
, and the upper bit corresponds toFile_Attribute_Compressed
. It has no equivalent in the units that come with Delphi, but you can use theJclFileUtils.faCompressed
symbol from the JCL.在 Jedi 代码库的 JclFileUtils 单元中,我发现:
如果 2080 是十六进制,那么就是它。
另请参阅:http://www.tek-tips。 com/viewthread.cfm?qid=1543818&page=9
编辑:
虽然 2080 id 十进制,并且 2080 dec = 820 十六进制,则属性是以下组合:
In
JclFileUtils
unit from Jedi Code Library I found:If 2080 is in hex then this is it.
Look also at: http://www.tek-tips.com/viewthread.cfm?qid=1543818&page=9
EDIT:
While 2080 id decimal, and 2080 dec = 820 hex then attributes are combination of:
这将提取 faDirectory 位,您不必担心压缩位设置与否。
This will extract the faDirectory bit and you dont have to worry about the compression bit set or not.