Mega Code Archive

 
Categories / Delphi / Files
 

Get the last access date to file

Title: Get the last access date to file Using Win32FindData structure you can find file's last access time in TFileTime type. Use FileTimeToSystemTime function for getting variable of the SystemTime structure, which holds the file's last access time. procedure TForm1.Button1Click(Sender: TObject); var MyS: TWin32FindData; MyTime: TFileTime; MySysTime: TSystemTime; begin if Edit1.text&lt&gt'' then begin FindFirstFile(PChar(Edit1.Text), MyS); MyTime:=MyS.ftLastAccessTime; FileTimeToSystemTime(MyTime, MySysTime); Label1.Caption:='Last Access - '+ IntToStr(MySysTime.wDay)+ '.'+ IntToStr(MySysTime.wMonth)+ '.'+ IntToStr(MySysTime.wYear); end; end;