-
Creating File Handles
This seems to me, to be the most basic question I've ever encountered, and YET I have been having trouble searching BOTH msdn and google to find it..what a bother, and even a search on cboard didn't show what I wanted...couldn't believe it, figured it might be my search terms, but I'm on a limited time frame and don't want to go through that. My brother has to get on the comp, so I have to ask it and get results quickly. I'm sure all three of these sources have information, I just don't have the time to build up search terms for them.
My question is, how do I create a file handle?
My usage is, to have my application run, and modify the applications creation/access/last write times using
Code:
SetFileTime(
HANDLE hFile,
const FILETIME* lpCreationTime,
const FILETIME* lpLastAccessTime,
const FILETIME* lpLastWriteTime
);
But, obviously, I need a handle to the application for this to work. I have every other argument i need, it's just the first one that's crucial to the success of this project.
I don't want an alternative mind you, I really want to stick to winapi functions, infact there's no other implementation that I would accept since I'm learning about winapi at this point in time.
-
Well you could use createfile
Code:
HANDLE CreateFile(
LPCTSTR lpFileName, // file name
DWORD dwDesiredAccess, // access mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile // handle to template file
);
-
I can't use CreateFile, since the exe that I want to change the attributes of, IS the exe that's running. and I don't want to create a copy of the application I'm running.
Now, that is assuming that I can modify the time attributes while It's running. If it doesn't let me do that, I still want to modify the time attributes of another exe without having to create the file or copy a file. That's just a bother if you ask me.
-
CreateFile doesn't copy a file. It opens an existing file, or a new file - read it up in MSDN. It's a very versatile function, possibly a little OTT :)
-
Thank you, I'll check that out :) Didn't know about the opening.