Windows CE .NET

This function is called by the operating system to transfer registry data to persistent storage. WriteRegistryToOEM is defined by the OEM.

BOOL WriteRegistryToOEM( 
  DWORD dwFlags, 
  LPBYTE lpData, 
  DWORD cbData 


[in] Read options specified by the system; currently, the only flag is REG_WRITE_BYTES_START, which indicates the start of the new registry file.
[in] Pointer to a buffer allocated by the OS and filled with registry bytes. The WriteRegistryToOEM function retrieves the bytes and saves them in persistent storage.
[in] Number of bytes in the buffer lpData passed in by the OS. When set to zero, then end of file has been reached.

Return Values

If this function succeeds, it returns TRUE. If this function fails, it returns FALSE.


The OS exposes the pWriteRegistryToOEM global pointer that is available in the OAL. To support persistent storage of the registry, you must implement the WriteRegistryToOEM function and assign the address of the function to pWriteRegistryToOEM. When the OS is instructed to flush the registry, the OS checks for a valid pWriteRegistryToOEM. If pWriteRegistryToOEM is valid, the OS continues to call this function to send bytes to the OEM implemented function until it returns FALSE, indicating that an error occurred, or the OS completes the flush.

The registry is notified that it needs to be flushed when the RegFlushKey function is called by an application.

Only a fully saved registry can be restored; attempting to restore a partial registry produces unpredictable results. If you try to save a partial registry, cbData is not set to zero. Then, when WriteRegistryToOEM is called, an error should be returned because the registry file is incomplete.

If you implement this function, you should document its support for your specific target device. Because the data format used by this function is different than the format used by the function RegCopyFile, the data cannot be exchanged.

The WriteRegistryToOEM and ReadRegistryFromOEM mechanism is only supported by the object store-based registry. To save and restore data in the hive-based registry, see the RegSaveKey and RegReplaceKey functions.

The data file saved by WriteRegistryToOEM cannot be imported directly by the function RegRestoreFile. Use RegCopyFile to save the data to be restored by RegRestoreFile, or use WriteRegistryToOEM to save the data to be imported by ReadRegistryFromOEM.


OS Versions: Windows CE 2.10 and later.
Header: Pkfuncs.h.
Link Library: Nk.lib.

See Also

pWriteRegistryToOEM | ReadRegistryFromOEM | RegFlushKey | RegSaveKey | RegReplaceKey | RegCopyFile | RegRestoreFile

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.