Register Login
ArticlesEmbedded101 Article    May 20, 2012
Click to Expand/Collapse Groups
Skip Navigation Links.
Collapse Windows Embedded Compact (CE)Windows Embedded Compact (CE)
Collapse Compact 7Compact 7
Build A Windows Network Projector wi...
Filter Device Drivers
Asynchronous I/O request support
Configure Flash Storage to Launch Co...
Collapse CE 6.0CE 6.0
Stream Driver with CEDriverWiz rev 0...
Connecting Visual Studio IDE to CE 6...
Windows CE: Save and Restore the Re...
Windows CE: Stream Interface Driver...
Windows CE: Persisting Registry Chan...
Windows CE: Enhanced BusEnum
Windows CE: Soft Reset
Windows CE: Reading a String from th...
Windows CE: Displaying Disk Informa...
Windows CE: Formatting TFAT
Windows CE: C# Application to Format...
Hive-Based Registry for CE 6.0
AutoLaunch for CE 6.0
Configure Flash Storage to Launch Co...
Collapse CE 5.0CE 5.0
Configure Flash Storage to Launch Co...
Collapse Platform Builder & OS DesignPlatform Builder & OS Design
Platform Builder: Automatically Flus...
Windows CE: Enhanced BusEnum
Windows CE: Soft Reset
Windows CE: Displaying Disk Informa...
Build A Windows Network Projector wi...
Collapse BSP, OAL & BootloaderBSP, OAL & Bootloader
Windows CE 6.0: User Mode KernelIoC...
Windows CE: Displaying Disk Informa...
Collapse RegistryRegistry
Platform Builder: Automatically Flus...
Windows CE: Save and Restore the Re...
Windows CE: Stream Interface Driver...
Windows CE: Persisting Registry Chan...
Windows CE: Reading a String from th...
Hive-Based Registry for CE 6.0
Collapse Device DriverDevice Driver
Stream Driver with CEDriverWiz rev 0...
Windows CE: Stream Interface Driver...
Windows CE: Enhanced BusEnum
Collapse File SystemFile System
Windows CE: Formatting TFAT
Windows CE: C# Application to Format...
Collapse Application DevelopmentApplication Development
Connecting Visual Studio IDE to CE 6...
Windows CE: Persisting Registry Chan...
Windows CE: Reading a String from th...
Windows CE: Formatting TFAT
Windows CE: C# Application to Format...
AutoLaunch for CE 6.0
Windows CE: Stream Interface Driver ...
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
Test entry
Asynchronous I/O request support
Configure Flash Storage to Launch Co...
Collapse Windows Embedded StandardWindows Embedded Standard
WES7
WES-2009
Windows XP Embedded
Target Designer
Enhanced Write Filter
Collapse NET Compact FrameworkNET Compact Framework
Windows CE: C# Application to Format...
Windows Phone 7
Misc.
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/

print



rating
  Comments

RegFlushKey
Created by Samphung in 2/18/2011 10:48:54 AM
Ran,

You cannot call RegFlushKey() directoy from managed code.
Here is an old post with the information you need.

http://www.pcreview.co.uk/forums/need-example-regsavekey-c-t2890539.html

RegFlushKey() is not recognized
Created by Ran in 2/18/2011 1:20:31 AM
Hi Sam,
I am currently developping a little application in C#, with the console application window. My application writes to registry, and I want those values to be kept after soft reset, but the problem is that the RegFlushKey() function is not recognized and won't compile.

Thanks a lot for help.

Ran


Your Name
Email
Website
Title
Comment
CAPTCHA image
Enter the code
 Copyright 2010 by Embedded101   Terms Of Use  Privacy Statement