如何获得目录的属性?(50分)

  • 主题发起人 主题发起人 faun
  • 开始时间 开始时间
F

faun

Unregistered / Unconfirmed
GUEST, unregistred user!
如何获得目录的属性?
 
FindFirstFile, 得到 WIN32_FIND_DATA.dwFileAttributes<br>然后 FindClose
 
看看Delphi的源代码吧。(示例如何使用Pipi.介绍的函数)<br><br>function FileAge(const FileName: string): Integer;<br>var<br>&nbsp; Handle: THandle;<br>&nbsp; FindData: TWin32FindData;<br>&nbsp; LocalFileTime: TFileTime;<br>begin<br>&nbsp; Handle := FindFirstFile(PChar(FileName), FindData);<br>&nbsp; if Handle &lt;&gt; INVALID_HANDLE_VALUE then<br>&nbsp; begin<br>&nbsp; &nbsp; Windows.FindClose(Handle);<br>&nbsp; &nbsp; if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);<br>&nbsp; &nbsp; &nbsp; if FileTimeToDosDateTime(LocalFileTime, LongRec(Result).Hi,<br>&nbsp; &nbsp; &nbsp; &nbsp; LongRec(Result).Lo) then Exit;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; Result := -1;<br>end;<br>
 
接受答案了.
 
后退
顶部