Archived

This topic is now archived and is closed to further replies.

101

CreateFile help pleaze

Recommended Posts

why am I having problems getting the file handle? HANDLE hfile = CreateFile("C:\\test.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); FILETIME creationtime; FILETIME lastaccesstime; FILETIME lastwritetime; GetFileTime(&hfile,&creationtime,&lastaccesstime, &lastwritetime); [edited by - 101 on October 16, 2003 8:17:48 PM]

Share this post


Link to post
Share on other sites
What error code do you get from GetLastError()? It will probably make no difference, but dwShareMode and dwFlagsAndAttributes should be 0, not NULL.

A LPFILETIME is only a pointer to a FILETIME, so you need to allocate some memory before using it with GetFileTime, or just:

FILETIME creationtime;
FILETIME lastaccesstime;
FILETIME lastwritetime;

GetFileTime(hfile, &creationtime, &lastaccesstime, &lastwritetime);

Note no address-of on hfile

Share this post


Link to post
Share on other sites
I''m not getting an error, but GetFileTime is returning bad values, which I am assuming is from a bad handle to the file.

Share this post


Link to post
Share on other sites