From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com> Subject: Re: Setting CreatedDateTime of a file Date: 10 Jun 1999 00:00:00 GMT Message-ID: Content-Transfer-Encoding: 8bit References: <7jnq3f$7gt14@forums.borland.com> Content-Type: text/plain; charset=iso-8859-1 Organization: TeamB Mime-Version: 1.0 Reply-To: 100113.1101@compuXXserve.com Newsgroups: borland.public.delphi.winapi > Does anyone know how to set the CreatedDateTime of a file. > I need to store the CreatedDateTime, ChangedDateTime of a file into a > database and when creating that file again from database I need to set > these. You have to use the API function SetFileTime for this: BOOL SetFileTime( HANDLE hFile, // identifies the file CONST FILETIME *lpCreationTime, // time the file was created CONST FILETIME *lpLastAccessTime, // time the file was last accessed CONST FILETIME *lpLastWriteTime // time the file was last written ); As you see it allows you to set all three timestamps in one go. The Delphi declaration in Window.pas is function SetFileTime(hFile: THandle; lpCreationTime, lpLastAccessTime, lpLastWriteTime: PFileTime): BOOL; stdcall; You need to do a bit of conversion to go from a TDatetime or DOS filetime, if you want to avoid that i suggest you store the file dates directly in Windows TFiletime format. Otherwise you would have to do what FileSetDate does for the last writetime for all three of them: function FileSetDate(Handle: Integer; Age: Integer): Integer; var LocalFileTime, FileTime: TFileTime; begin Result := 0; if DosDateTimeToFileTime(LongRec(Age).Hi, LongRec(Age).Lo, LocalFileTime) and LocalFileTimeToFileTime(LocalFileTime, FileTime) and SetFileTime(Handle, nil, nil, @FileTime) then Exit; Result := GetLastError; end; Peter Below (TeamB) 100113.1101@compuserve.com) No replies in private e-mail, please, unless explicitly requested!