hi, what Im trying to do is get the last write time for a registry key particulay one of the keys in the following path
HKEY_LOCAL_MACHINE -> SYSTEM-current control set-> control-Device classes ->{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
I know that the keys in here correspond to the last times your USB device was plugged into your computer. Thing is i have the following code which i thought worked as it gets the time and date and everything which seems right BUT when ive checked a bit further it doesn't seem to be retrieving the correct time. for example i ran my program and it got a time of 20:00 31/07/2008. I then unplugged my device and replugged which should have updated the keys last write time but when i ran my program my time and date output never changed! hmmm.
I guess what im trying to say is, my code is totally wrong it just isnt completely right can anyone offer any suggestions cos im totally stumped here
Code:
if( RegOpenKey(HKEY_LOCAL_MACHINE,subkeyLPIT,&hKeyLPIT) == ERROR_SUCCESS)
{
FILETIME writeTimeLPITs;
int i = 0;
while(RegEnumKeyEx(hKeyLPIT, i++, bufLPIT, &dwBufSizeLPIT, 0, 0, 0, &writeTimeLPITs) == ERROR_SUCCESS)
{
cout << "LAST WRITE TIME OF KEY : " << bufLPIT << endl;
dwBufSizeLPIT = sizeof(bufLPIT);
/**************************************time for key (DEVICE FIRST PLUGGED IN TIME)*************************************************/
SYSTEMTIME stLocal;
FileTimeToSystemTime( &writeTimeLPITs, &stLocal );
cout << stLocal.wYear << "/"
<< stLocal.wDay << "/"
<< stLocal.wMonth << " "
<< stLocal.wHour << ":"
<< stLocal.wMinute << ":"
<< stLocal.wSecond << ":"
<< stLocal.wMilliseconds ;
I did think about trying something similar on msdn which was the getfiletime function. Ive pasted the example of theirs below which I think could possibly be what i need to use as it uses some windows functiony thing (sorry im guessing) to retrieve the last write time. However I am unsure how to user getfiletime on a registry key. If anyone could point me in the right direct please?
Code:
FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC, stLocal;
DWORD dwRet;
// Retrieve the file times for the file.
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
Sorry for the long post but this problem is soo frustrating! any help would be MUCH appreciated!!