Partager via


Flush-On-Close Registry Flushing (Windows Embedded CE 6.0)

1/6/2010

If you have a hive-based registry, you can choose whether to use aggressive flushing in the registry. Aggressive flushing is also called flush-on-close because, with aggressive flushing, the OS calls RegFlushKey every time a registry key is closed with RegCloseKey.

With a hive-based registry, RegFlushKey commits all registry changes in a particular key to persistent storage. The implementation is OEM-dependent, and may also write out other keys. Thus, if your device has persistent storage, aggressive flushing can cause performance issues because of the time required to run RegFlushKey.

Note

Frequent calls to this function can have a significant negative effect on performance and should be used with caution.

To mitigate possible performance degradation and data loss issues with aggressive flushing, flushing begins only after all processes in the initialization sequence have already started. For example, if the flush fails due to an out-of-disk error, the registry key is still closed, and no transactions are left in an unresolved state. In such a situation, RegCloseKey returns an error that indicates a failed flush.

Enabling flush-on-close

Aggressive flushing is set in the registry in a RegistryFlags value that is read-only at startup.

The following registry key example shows how to enable aggressive flushing:

[HKEY_LOCAL_MACHINE\init\BootVars]
   "RegistryFlags"=dword:1

Setting the RegistryFlags value to one enables aggressive flushing.

In a device with persistent storage, a call to RegFlushKey causes the OS to flush the entire registry to the hive. If your device has persistent storage, do not set this value. If this registry value is not present or is set to zero, the registry flushes nondeterministically.

For more information about registry flushing, see Options for Registry Flushing.

See Also

Concepts

Registry Flushing
Options for Registry Flushing