다음을 통해 공유


Data Persistence with the RAM-based Registry Using the OAL (Windows Embedded CE 6.0)

1/6/2010

The RAM-based registry supports two OEM adaptation layer (OAL) save-and-restore methods. OEMs can use these methods to persist registry data when the RAM, which contains the object store, is not powered. The methods can also be used to provide protection against invalid data configurations. The preferred method for persisting data with the RAM-based registry is to include the OEMRegistry.dll sample file in your OS image. For more information, see Persisting Data with the RAM-Based Registry.

The first method is based on the RegCopyFile and RegRestoreFile functions. RegCopyFile saves the entire registry to a file, and RegRestoreFile sets up the registry to be replaced with the data in the specified file when the device is next started. To persist the registry when a device is turned off, first use RegCopyFile to save the data to a persistent file. On the next cold boot, call RegRestoreFile to prepare the registry to be replaced with data in the file, and perform a warm reboot to complete the registry replacement. This manner of registry persistence is easy to implement, but because it requires both a cold and a warm boot to restore the registry after a device was turned off, it is relatively slow. This method is better suited for providing backup to protect against errors than for providing registry persistence.

The second method gives the OEM responsibility for persisting the data. An OEM can implement the WriteRegistryToOEM and ReadRegistryFromOEM functions in the OAL. These functions are called by the registry code to save and restore the data. When an application calls the RegFlushKey function, the OS makes a series of calls to WriteRegistryToOEM to pass the entire registry to the OEM, which stores the data on any persistent media. Then, while the OS is starting, it makes another series of calls to ReadRegistryFromOEM to receive the data from wherever the OEM stored it. The difficulty in using this mechanism is that file system calls, such as CreateFile, ReadFile, and WriteFile, cannot be used to read the data from storage during ReadRegistryFromOEM. They can be used during WriteRegistryToOEM, but the block and file system drivers needed to read from external media are not started until after the registry is initialized. Therefore, implementing ReadRegistryFromOEM is difficult, Code to read from the persistent media must be added to the OAL. However, this mechanism has the benefit of requiring only a single boot to restore the registry.

The following pairs of functions cannot be intermixed: RegCopyFile and RegRestoreFile, and WriteRegistryToOEM and ReadRegistryFromOEM. The file produced by RegCopyFile is not the same as that produced by WriteRegistryToOEM.

See Also

Reference

RegCopyFile
RegRestoreFile
RegFlushKey

Concepts

RAM-Based Registry
RAM-Based Registry Setup
Persisting Data with the RAM-Based Registry

Other Resources

WriteRegistryToOEM
ReadRegistryFromOEM