Get a file’s date – delphi

Get a file’s date function delphi

// Get a file's date

function GetFileDateTime(const FileName: TFileName): TDateTime;
var
  FStruct: TOFSTRUCT;
  wndFile: Integer;
begin
  wndFile := OpenFile(PChar(FileName), FStruct, OF_SHARE_DENY_NONE);
  Result  := FileDateToDateTime(FileGetDate(wndFile));
  CloseHandle(wndFile);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Opendialog1.Execute then
    label1.Caption := DateTimeToStr(GetFileDateTime(Opendialog1.FileName));
end;