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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DrDelphiCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.