Hi all,
I am very new to VC++, (VB Convert), and am only writing my second C++ program.
I am looking to write either a FILETIME struct or a SYSTEMTIME struct to a file for later usage. I am using the CreateFile, WriteFile, CloseHandle APIs to handle writing to file.
But I'm not sure how to handle the data if I want to retrieve it later.
- Is it possible to write the FILETIME to a file in binary using the WriteFile API?
- or... is there a way to write the 2 DWORD values of the FILETIME struct as binary that can easily be retrieved as 2 separate values later?
- Or should I leave it as system time and then put it into the file as a string value that I can tokenize during retrieval?
Code I have thus far is
Code:
SYSTEMTIME stCurrent;
FILETIME ftCurrent;
HANDLE hWriteFile;
LPDWORD lpBytesWritten = 0;
long lRetVal;
GetSystemTime(&stCurrent);
SystemTimeToFileTime(&stCurrent, &ftCurrent);
hWriteFile = CreateFile("C:\\Temp\\file.dat",
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
lRetVal = WriteFile(hWriteFile,
&ftCurrent,
sizeof(ftCurrent),
lpBytesWritten,
NULL);
CloseHandle(hWriteFile);
if(lRetVal == ERROR_SUCCESS){return true;]
else{return false;}
Thanks one and all for any advice you can lend!
PS...
The purpose of the class I'm working on is to catch the current system time. Then, following an application installation, compare the lastwritetime of the CLASSES_ROOT and LOCAL_MACHINE reg keys to see what was changed by the installation.
I am calling the GetSystemTime API and then, potentially, using the SystemTimeToFileTime API to convert to FILETIME.