FileSetDate And FileGetDate

Could someone please send me an example on how to use the FileSetDate function and the FileGetDate function.
brettawvAsked:
Who is Participating?
 
DrDelphiConnect With a Mentor Commented:
Function GetFileCreationTime(Const FName: String; Var cTime: TDateTime):
Boolean;
Var
  fHandle: HFILE;
  fStruct: _OFSTRUCT;
  ftCreation: _FILETIME;
  ftLastAccess: _FILETIME;
  ftLastWrite: _FILETIME;
  sTime: _SYSTEMTIME;
Begin
  fHandle := OpenFile(PChar(FName), fStruct, OF_READ);
  Result := (fHandle <> HFILE_ERROR);
  If Result Then
  Begin
    Result := GetFileTime(fHandle, @ftCreation, @ftLastAccess,
@ftLastWrite);
    If Result Then
    Begin
      Result := FileTimeToSystemTime(ftCreation, sTime);
      cTime := SystemTimeToDateTime(sTime);
    End;
  _lclose(fHandle);
  End;
End;
0
 
Fatman121898Commented:
Hi brettawv,

Before you use these functions, you should open file using OpenFile function (see help on SysUtils) passing OF_EXIST value to parameter fuMode. This function should return you file handle (if file exists) wich you can use as parameter in FileSetDate and FileGetDate.

Regards,
Jo.
0
 
Fatman121898Commented:
Hey DrDelphi, your answer appeared while I wrote my comment - obviously we are at the same opinion :-).

Jo.
0
 
DrDelphiCommented:
Fatman,
  So it would seem!<g>

0
 
brettawvAuthor Commented:
I did find the function FileAge which allows me to use a string name for a file instead of finding the file handle.
Your example helped to get me started. Thanks.
0
All Courses

From novice to tech pro — start learning today.