CreateFile for directories?
I use the API CreateFile function to get a handle to a file, but it doesn't work if the file is a directory, the function returns -1 = "invalid handle value". Is there some work around? I need the handle in order to call SetFileTime and thus modify the file or directory time stamp.
Re: CreateFile for directories?
Quote:
Originally Posted by myself
I use the API CreateFile function to get a handle to a file, but it doesn't work if the file is a directory, the function returns -1 = "invalid handle value". Is there some work around? I need the handle in order to call SetFileTime and thus modify the file or directory time stamp.
Well, I've just read that CreateFile can only make read access to directories, unlike files. Thus the question is, how can I write to a directory file to change its time stamp?
Re: CreateFile for directories?
I have found this but it doesn't apply to Win98.
Re: CreateFile for directories?
BUMP
So, to cut the long story short, how to time/date stamp a directory?
Re: CreateFile for directories?
Check this example at pscode.com: ChangeFolderTimeAttributes
it says: "This code allows for the changing of the access; modified; and created time stamps for folders..."
Re: CreateFile for directories?
Quote:
Originally Posted by jcis
Check this example at pscode.com:
ChangeFolderTimeAttributes
it says:
"This code allows for the changing of the access; modified; and created time stamps for folders..."
Looks like I'll have to study this code very carefully, but it's a nice demo to set me started.
Thanks for the hint.
Re: CreateFile for directories?
Quote:
Originally Posted by krtxmrtz
Looks like I'll have to study this code very carefully, but it's a nice demo to set me started.
Thanks for the hint.
Unfortunately this code is giving me exactly the same error (see my opening post) in the CreateFile procedure. I wonder if it's not intended for Win98, but I still haven't had a chance to try it under WinXP.
Re: CreateFile for directories?
Quote:
Originally Posted by krtxmrtz
Unfortunately this code is giving me exactly the same error (see my opening post) in the CreateFile procedure. I wonder if it's not intended for Win98, but I still haven't had a chance to try it under WinXP.
Just tried under Windows XP: same thing (returned handle: -1)