last write time

This is a discussion on last write time within the C++ Programming forums, part of the General Programming Boards category; hi, what Im trying to do is get the last write time for a registry key particulay one of the ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    99

    last write time

    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!!

  2. #2
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    I don't have answer to your question, but this has nothing to do with C++ and much to do with Windows programming, so next time, post in the correct board.
    I hate real numbers.

  3. #3
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    After looking on MSDN, I can tell you that if you are interested in knowing the last write time of a key, then you need to look at RegQueryInfoKey. I think that's what you were looking for. If you are looking for the last time a value (Microsoft terminology) has been written, then, I couldn't tell, it looks like there's no way to get this, but I might be wrong, I didn't read the whole "About the registry" documentation, and I'm far from being a knowledgeable Windows programmer.

    But I did wrote a small app to see if it was indeed working (and it does)... here it is... sharing it with the community... Yes.

    RegistryKeyInfo.zip

    Still, next time, post in the right section.

    EDIT: But after rereading your first post, I'm not sure this is of any help, because as far as I can see from the poorly indented first section of your code, well, the problem might be in the key not being updated. I don't know.
    Last edited by foxman; 07-31-2008 at 08:01 PM.
    I hate real numbers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  2. Time between Military Hours
    By StarOrbs in forum C++ Programming
    Replies: 18
    Last Post: 03-01-2005, 06:46 PM
  3. Some humour...
    By Stan100 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-06-2003, 10:25 PM
  4. The Timing is incorret
    By Drew in forum C++ Programming
    Replies: 5
    Last Post: 08-28-2003, 05:57 PM
  5. This should be the Cprogramming.com anthem!
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-21-2002, 12:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21