다음을 통해 공유


RegSaveKey (Windows Embedded CE 6.0)

1/6/2010

This function saves the specified key and all its subkeys and values to a new file. If the specified key is not a predefined root, it saves to the root of the hKey parameter.

Syntax

LONG RegSaveKey( 
  HKEY hKey,
  LPCTSTR lpFile,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes
);

Parameters

  • hKey
    [in] Specifies a handle to the key in which the save operation is to begin or any of the following predefined reserved handle values:

    • HKEY_LOCAL_MACHINE
    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_USERS
  • lpFile
    [in] Pointer to a null-terminated string containing the name of the file in which the specified key and subkeys are saved.
  • lpSecurityAttributes
    [in] Must be set to NULL.

Return Value

ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call the FormatMessage funciton with the FORMAT_MESSAGE_FROM_SYSTEM flag set.

If GetLastError returns ERROR_NOT_SUPPORTED, this function is not supported on an object store-based registry.

Remarks

This funciton is only supported only for a hive-based registry. To save and restore data in the object store-based registry, see RegCopyFile and RegRestoreFile.

Although you can call this function with any registry key, it only provides two choices. If it is called with HKEY_LOCAL_MACHINE, HKEY_CLASSES_ROOT, HKEY_USERS, or any key under those roots, it saves a copy of the entire system hive, which includes all keys under these roots. If it is called with HKEY_CURRENT_USER or any key under it, it saves a copy of the entire user hive, which includes all keys under HKEY_CURRENT_USER.

You can use the file created by this function in subsequent calls to the RegReplaceKey function with HKEY_LOCAL_MACHINE to restore the system registry hive. To restore a saved user hive, move the file into the user's profile directory while the user is not logged on. Subsequent calls to the SetCurrentUser function use the restored hive.

Requirements

Header pwinreg.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later

See Also

Reference

Registry Functions
RegReplaceKey
SetCurrentUser
RegCopyFile
RegRestoreFile

Concepts

Data Persistence with the Hive-Based Registry

Other Resources

FormatMessage