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.
LONG RegSaveKey( HKEY hKey, LPCTSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes );
[in] Specifies a handle to the key in which the save operation is to begin or any of the following predefined reserved handle values:
[in] Pointer to a null-terminated string containing the name of the file in which the specified key and subkeys are saved.
[in] Must be set to NULL.
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.
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.