Re: [D5] set folder creation date



Fodox wrote:
i have to set the creation date of a folder, this is my code:

The JCL already has functions that should be able to do what you need.

http://jcl.sf.net/

hDir:=OpenFile(pChar(stDir), struct, OF_READWRITE or
OF_SHARE_EXCLUSIVE);

It's been nearly ten years. I think it's time to stop using OpenFile and move on to CreateFile, as the documentation recommends.


if hDir>0 then begin

If OpenFile fails, it returns HFile_Error. I have no idea what the numeric value of that constant is, but it doesn't matter. All you need to do is check whether hDir is equal to (not greater than or less than) that constant.


  SetFileTime(hDir,@DirTime,@DirTime,@DirTime);
  FileClose(hDir);
end;

it don't work: reading the struct's data i always see ERROR 5 (file
access denied?). why that?

Maybe you can't get exclusive read-write access to the directory? That might be caused by some other program having that directory open as its current directory.


--
Rob
.