...get a file's date ?

Author: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch

Category: Files

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;

 

printed from
www.swissdelphicenter.ch
developers knowledge base