Automatically save changes to Windows CE registry
I have discussed flushing the registry from applications before in Windows CE: Persisting Registry Changes from an Application. It is possible to set up the file system to automatically flush the registry when using hive registry.
The system will automatically flush the registry when the system suspends. Filesys can be configured to flush the registry when changes occur by setting some registry values.
[HKEY_LOCAL_MACHINE\System\ObjectStore\RegFlush]
“SpawnThread"=dword:1
"FlushPriority256"=dword:FF
"ActivityThreshold"=dword:100
"FlushPeriod"=dword:3E8
These settings tell filesys to flush the registry when there are 256 changes or when there are any changes with a second. The values are:
· SpawnThread – causes filesys to start a thread to monitor for registry changes
· FlushPriority256 – set the thread priority of the thread that monitors for changes. By setting this to a low priority, the thread is less likely to flush the registry if applications are busy which can improve performance at the risk that the registry will not be flushed.
· ActivityThreashold – sets the number of changes to the registry that will cause the registry to be flushed. If your applications make significant changes often consider setting this to a larger value.
· FlushPeriod – sets a timeout value that causes the thread to check for any changes to the registry and flush if any changes have occurred
These settings will automatically be added to the registry if the project sets the environment variable PRJ_ENABLE_REGFLUSH_THREAD. I recommend setting these in platform.reg or project.reg instead though so that the values can be controlled and tested.
Note: This article is written by Bruce Eitman, and is posted to the Embedded101 site with Bruce’s permission.
Copyright © 2010 – Bruce Eitman
http://geekswithblogs.net/BruceEitman/