Results 1 to 8 of 8

Thread: CreateFile for directories?

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: CreateFile for directories?

    I have found this but it doesn't apply to Win98.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: CreateFile for directories?

    BUMP

    So, to cut the long story short, how to time/date stamp a directory?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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..."

  6. #6

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  8. #8

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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)
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width