Windows CE: Persisting Registry Changes from an Application

Windows CE: Persisting Registry Changes from an Application
Created by samphung on 11/20/2010 10:54:27 PM

Saving changes to the Windows CE registry from an application  


Windows CE devices may or may not persist the registry when power is removed or through a hard reset. The decision is up to the OEM to implement a way to persist the registry. So your device may lose your registry settings. The good news is that many Windows CE devices do have a way to persist the registry. Microsoft provides two methods for the OEM to implement registry persistence:

1.       Hive based registry – in this method, the Filesys is set up with a non-volatile disk to save the registry. This is probably the only way that is still being implemented on devices today, primarily because it is easy to implement.

2.       WriteRegistryToOEM/ReadRegistryFromOEM – in this method, the OEM implements these two functions in the kernel to save and restore the registry. This method pre-dates the hive based registry that was introduced in Windows CE 4.0.

These provide the OS with a method for saving the registry to non-volatile storage. It is up to you to request that the system persist the registry when needed. Many Windows CE devices use flash memory to persist the registry, and flash memory is relatively slow so automatically persisting can come with a performance hit. The OEM can configure filesys to automatically persist the registry when changes are made, but this may not be set up so don’t rely on it unless you know that it is set up.

Your application should request that the registry be persisted when appropriate by calling RegFlushKey(). RegFlushKey() takes one parameter; a handle to a registry key. It can be passed one of the predefined keys like HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER or the key that was being used to write to the registry. The application should call RegFlushKey() after writing a set of registry values rather than after each write because it is more efficient to call it after writing a set of values.

If your system is using hive based registry, it will persist any registry changes when the system suspends. So if it is important to quickly suspend, then your application must call RegFlushKey() when writing to the registry. If the registry has already been persisted, then the data on disk does not need to be updated when the system suspends. On the other hand, suspending the system is a handy way to persist the registry when using an application, like the control panel applets, that don’t call RegFlushKey().

A handy application to have in your tool bag is a simple application that calls RegFlushKey().  You can use this while editing the registry or setting things up in the Control Panel to save your settings.

------------------------------------------------------------------------------------------------------------------------------

Note:  This article is written by Bruce Eitman, and is posted to the Embedded101 site with Bruce’s permission.

Copyright © 2010 – Bruce Eitman – All Rights Reserved

http://geekswithblogs.net/BruceEitman/

Embedded101 Articles

Click to Expand/Collapse Groups
Skip Navigation Links.
Collapse Windows Embedded Compact (CE)Windows Embedded Compact (CE)
Collapse Compact 7Compact 7
Collapse CE 6.0CE 6.0
Collapse CE 5.0CE 5.0
Collapse Platform Builder & OS DesignPlatform Builder & OS Design
Collapse BSP, OAL & BootloaderBSP, OAL & Bootloader
Collapse RegistryRegistry
Collapse Device DriverDevice Driver
Collapse File SystemFile System
Collapse Application DevelopmentApplication Development
IBW & ICE
Stream Driver with CEDriverWiz rev 0...
Connecting Visual Studio IDE to CE 6...
Platform Builder: Automatically Flus...
Windows CE: Save and Restore the Re...
Windows CE: Stream Interface Driver...
Windows CE: Persisting Registry Chan...
Windows CE: Enhanced BusEnum
Windows CE: Reading a String from th...
Windows CE: Displaying Disk Informa...
Windows CE: Formatting TFAT
Windows CE: C# Application to Format...
Build A Windows Network Projector wi...
Hive-Based Registry for CE 6.0
AutoLaunch for CE 6.0
Hello all
Filter Device Drivers
Asynchronous I/O request support
Configure Flash Storage to Launch Co...
CEDriverWiz Version 2.00 User Manual
CEDriverWiz V2.00: About this releas...
Installing CEDriverWiz for Visual St...
CEDriverWiz Version 2.00: An Example
CEDriverWiz Version 2.00: Using the ...
Collapse Windows Embedded StandardWindows Embedded Standard
Collapse NET Compact FrameworkNET Compact Framework
Windows Phone 7
Misc.
Turkish porno izle video site in rokettubeporno izle