Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Registry Time/Date Stamp

Digital_NomadDigital_Nomad Member Posts: 3
Hi fellow coders ;)

I'm going gray here over something and it is not because of old age LOL. I need to access creation/modification time or date stamps for registry keys I create. For example I might create a new key somewhere under the current user section and when it is called later on, I need to find the date it was last modified or created. Basically the same as files which have file creation and modification dates...

I would be most greatfull for any help in finding the code snippets to make this idea float.

Best wishes,

Digital Nomad

PS: So far the closest solution I could find is an API call perhaps someone here knows it and knows how to impliment it in C++.

http://www.windowsdevcenter.com/pub/a/windows/2004/06/15/VB_Registry_Keys.html?page=last

[link=http://www.windowsdevcenter.com/pub/a/windows/2004/06/15/VB_Registry_Keys.html?page=last][/link]

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    Here is the c++ explaination of that function

    http://msdn2.microsoft.com/en-us/library/ms724862.aspx


    just call it in a loop as explained in that link.
    Conversation should be pleasant without scurrility, witty without affectation, free without indecency, learned without conceitedness, novel without falsehood.
    William Shakespeare
  • Digital_NomadDigital_Nomad Member Posts: 3
    : Here is the c++ explaination of that function
    :
    : http://msdn2.microsoft.com/en-us/library/ms724862.aspx
    :
    :
    : just call it in a loop as explained in that link.

    Hey there, thanks for taking the time to reply...I am aware of MSDN, but most of the time find their two line definitions and cryptic function declarations and lack of clear cut code samples very "un-helpfull", really a pitty. Online sources like this are millions of times better not to mention the kind heartedness of people like yourself willing to take some of your time to help a total stranger.

    The other day I needed to setup a DDE link to a trading platform from C++ - boy was that a battle to find usable info on that topic...nothing...eventually trial and error got me connected, as in this case as well. I eventually figured it out and can now get the time stamp of the registery key of my choice. The returned time is in FILETIME format which I can convert to SYSTEMTIME format...which is where I am stuck again at the moment. I use something like:

    FileTimeToSytemTime(&ft,&st);

    where &ft is the file time returned by the RegQueryInfoKey(...) call and &st is the SYSTEMTIME variable. Now to get that result to some string/char format so that I can display the value using MessageBox(...);

    Hope you kind folk can help me out on this one.

    Happy coding and kind regards from a litrally FREEZING South Africa.

    Digital Nomad

    PS: I found this: http://www.codeproject.com/useritems/FormatString.asp quite tricky to get it going, but I am now hoping there is an easier cleaner way...please help :-) ( the latter solution also does not seem to work in VS C++ 6 got it going in my VS2003
  • stoberstober Member Posts: 9,765 ✭✭✭
    I still like to use C's sprintf() to format strings because it seems the easiest way to do it. In your case if you want the string in DD/MM/YYYY format then you need a format string that looks like this: "%02d/%02d/%04d". So the sprintf() function would be
    [code]
    char date[40] = {0};
    SYSTEMTIME sys;
    sprintf(date,"%02d/%02d/%04d", sys.wDay,sys.wMonth,sys.wYear);
    [/code]
    =============================================
    never lie -- the government doesn't like the competition. (Author unknown)
  • Digital_NomadDigital_Nomad Member Posts: 3
    : I still like to use C's sprintf() to format strings because it seems
    : the easiest way to do it. In your case if you want the string in
    : DD/MM/YYYY format then you need a format string that looks like

    Fantastic !!! It works !!! No one can ever argue with simplicity LOL :D thank you very very much for that tip... I always get a little confused with those string formatting characters, gotto find me a good refference to them ASAP !!!

    Once more [b]thank you very much [/b]for helping me out here, I owe you one ;)

    Best wishes,

    Digital Nomad

    PS: Just thought I'd pop this in here seeing that it applies to the solution, nice summary of all the [b]sprintf[/b] format charracters with nice examples etc...just in case someone else is on the same hunt someday: http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html


Sign In or Register to comment.