Compartir a través de


RegReplaceKey (Windows CE 5.0)

Send Feedback

This function replaces the file backing a registry key and all its subkeys with another file, so that when the system is next started, the key and subkeys will have the values stored in the new file.

LONGRegReplaceKey(HKEYhKey,LPCTSTRlpSubKey,LPCTSTRlpNewFile,LPCTSTRlpOldFile);

Parameters

  • hKey
    [in] The hKey parameter must be HKEY_LOCAL_MACHINE.
  • lpSubKey
    [in] Must be NULL.
  • lpNewFile
    [in] Pointer to a null-terminated string containing the name of the file with registration information. This file is typically created by using the RegSaveKey function. This value can be set to NULL.
  • lpOldFile
    [in] Pointer to a null-terminated string containing the name of a file that receives a backup copy of the registry information being replaced. This value can be set to NULL.

Return Values

The function may fail with GetLastError returning the value of the function because it is not supported on the object store-based registry.

The function may fail with GetLastError returning ERROR_ACCESS_DENIED because only trusted application are allowed to call RegReplaceKey.

The function may fail with GetLastError returning ERROR_NOT_SUPPORTED because it is not supported on the object store-based registry.

Remarks

This function can only be used to restore a backup copy of the system registry hive, which contains all data under HKEY_LOCAL_MACHINE, HKEY_CLASSES_ROOT, and HKEY_USERS. To restore a saved user hive, move the file into the user's profile directory while the user is not logged in. Subsequent calls to SetCurrentUser will use the restored hive.

The system hive is unmounted and will not be remounted until the system is restarted. This means the system registry becomes unusable. Both files will remain closed after this call. The current registry hive is moved to lpOldFile.

If lpNewFile is non-NULL, that file is renamed to be the registry hive, and will be mounted on the next boot.

If lpNewFile is NULL, a default hive will be loaded from ROM on the next boot.

The RegReplaceKey API is only supported by the hive-based registry. To save and restore data in the object store-based registry, see RegCopyFile and RegRestoreFile.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Pwinreg.h.
Link Library: Coredll.lib.

See Also

RegSaveKey | RegCopyFile | RegRestoreFile | SetCurrentUser | Persisting Data with the Hive-Based Registry

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.