Search code examples
timewindows-ce

How to persist system time settings on Windows CE


I am using Windows CE 6.0 device and when I set the device time (programatically or manually), the device doesn't remember the setting when I unplug its power supply.

How can I make sure that the time settings are saved? I need to synchronize the device time with server programatically and this makes it difficult when the device power goes off.

I am guessing the problem might be with some registry settings not being persisted, but I am not sure if time is stored in these and I didn't find a way how to force to store them.

Thank you for suggestions.

EDIT: After the restart of the device, the clock doesn't reset completely, it just returns to wrong time. The time of the device after restart is always about 1 hour forward.


Solution

  • If the device is losing it's time when you remove power, it's because it doesn't have a battery-backed clock or the battery for the clock is dead. Without any power, there's no way for the device to maintain time, and there's no way for you to get the device to save its time, short of adding some form of back-up power (or replacing the battery, if it has one).

    EDIT

    If the clock is resetting back to the system default, but only changing by hours, then that strongly indicates that it's losing the DST or timezone settings. Both of these are stored in the registry, so it's likely that your registry settings aren't persisting. This could be for a couple reasons:

    1. You've made a change to the registry, but not told the OS to save the change. The OS configuration might be set to save changes periodically, or only when explicitly told. Your best bet here is to make the changes to the clock (I assume you're changing time zone and/or DST when you adjust the clock?) then explicitly call the RegFlushKey API to force a registry save.
    2. Your device doesn't have a persistent registry. Only the OEM could fix that. Testing is simple, create a registry entry, call RegFlushKey and restart to see if it's still there. If it's not then your device doesn't persist registry settings and you're probably out of luck.