What’s the best data type and/or format to write and read a date and time value in the Windows Registry?
I’m using C++ with MFC and working with CTime and CTimeSpan objects, but I feel comfortable using the CRT library as well.
My understanding is that to correctly represent a time value, a 64-bit integer should be used. That precludes using MFC methods such as WinAppEx::WriteInt().
For readability and debugging purposes, I would have liked to use the CTime::FormatGmt() method to write a string to the registry and then read and parse it later, but the lack of a MSVC runtime implementation of strptime() prevents easy parsing on read. While I could implement strptime(), I’m hoping for a lighter-weight solution.
I have not explored the COleDateTime classes yet.
Thanks in advance, this is my first StackOverflow question.
Use CTime::GetTime, and store the returned 64-bit integer into registry. When loading pass the same integer to
CTimeconstructor.You may also consider using time functions.