欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

获取文件最后写入时间

程序员文章站 2022-05-24 12:30:12
...
   subtype FILETIME is QWord;

   type WIN32_FIND_DATAA is record
      FileAttributes     : DWORD;
      CreationTime       : FILETIME;
      LastAccessTime     : FILETIME;
      LastWriteTime      : FILETIME;
      FileSize           : QWORD:=0;
      Reserved           : QWORD;
      FileName           : String (1 .. 260);
      AlternateFileName  : String (1 .. 14);
   end record with Pack;


   function FindFirstFile(Path:String;pf:access WIN32_FIND_DATAA) return int with Import,Convention=>Stdcall,external_Name=>"FindFirstFileA";


   function GetFileLastWriteTime(fn:String) return QWORD is

      FD:aliased WIN32_FIND_DATAA;

      fnc:constant String:=fn&Nul;

      hf:int:=FindFirstFile(fnc,FD'Access);
   begin

      if hf /= 0 then
         return FD.LastWriteTime;
      end if;

      return 0;

   end GetFileLastWriteTime;