The GetFileTime function retrieves the date and time that a file was created, last accessed, and last modified.
BOOL GetFileTime(
HANDLE hFile, // identifies the file
LPFILETIME lpCreationTime, // address of creation time
LPFILETIME lpLastAccessTime, // address of last access time
LPFILETIME lpLastWriteTime // address of last write time
);
Use the GetFileTime API function.The C protype like this:
BOOL GetFileTime(
HANDLE hFile, // identifies the file
LPFILETIME lpCreationTime, // address of creation time
LPFILETIME lpLastAccessTime, // address of last access time
LPFILETIME lpLastWriteTime // address of last write time
);
The lpLastWriteTime variable include the value that you want.
Use the GetFileTime API function.The C protype like this:
BOOL GetFileTime(
HANDLE hFile, // identifies the file
LPFILETIME lpCreationTime, // address of creation time
LPFILETIME lpLastAccessTime, // address of last access time
LPFILETIME lpLastWriteTime // address of last write time
);
The lpLastWriteTime variable include the value that you want.
procedure TForm1.Button1Click(Sender: TObject);
var
iFileHandle : Integer;
UpdateTime:TDateTime;
begin
if OpenDialog1.Execute then
begin
iFileHandle := FileOpen(OpenDialog1.FileName, fmOpenRead);
UpDateTime:=FileDateToDateTime(FileGetDate(iFileHandle));
FileClose(iFileHandle);
end;
label1.caption:=datetimetostr(Updatetime);
end;
var
FileHandle : Integer;
DateTime:TDateTime
begin
FileHandle := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);
DateTime:=FileDateToDateTime(FileGetDate(FileHandle));
Fileclose(FileHandle);
end;