Skip to content

Latest commit

 

History

History
154 lines (98 loc) · 5.54 KB

nf-winreg-regreplacekeya.md

File metadata and controls

154 lines (98 loc) · 5.54 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winreg.RegReplaceKeyA
RegReplaceKeyA function (winreg.h)
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. (ANSI)
RegReplaceKeyA
winreg/RegReplaceKeyA
base\regreplacekey.htm
winprog
f968fa71-edc8-4f49-b9fa-1e89224df33b
12/05/2018
RegReplaceKey, RegReplaceKey function, RegReplaceKeyA, RegReplaceKeyW, _win32_regreplacekey, base.regreplacekey, winreg/RegReplaceKey, winreg/RegReplaceKeyA, winreg/RegReplaceKeyW
winreg.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
RegReplaceKeyW (Unicode) and RegReplaceKeyA (ANSI)
Advapi32.lib
Advapi32.dll
Windows
19H1
RegReplaceKeyA
winreg/RegReplaceKeyA
c++
APIRef
kbSyntax
DllExport
Advapi32.dll
API-MS-Win-Core-Registry-l2-1-0.dll
advapi32legacy.dll
API-MS-Win-Core-Registry-l2-2-0.dll
RegReplaceKey
RegReplaceKeyA
RegReplaceKeyW

RegReplaceKeyA function

-description

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.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy Service instead of the registry functions.

-parameters

-param hKey [in]

A handle to an open registry key. This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:

HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS

-param lpSubKey [in, optional]

The name of the registry key whose subkeys and values are to be replaced. If the key exists, it must be a subkey of the key identified by the hKey parameter. If the subkey does not exist, it is created. This parameter can be NULL.

If the specified subkey is not the root of a hive, RegReplaceKey traverses up the hive tree structure until it encounters a hive root, then it replaces the contents of that hive with the contents of the data file specified by lpNewFile.

For more information, see Registry Element Size Limits.

-param lpNewFile [in]

The name of the file with the registry information. This file is typically created by using the RegSaveKey function.

-param lpOldFile [in]

The name of the file that receives a backup copy of the registry information being replaced.

-returns

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

-remarks

There are two different registry hive file formats. Registry hives created on current operating systems typically cannot be loaded by earlier ones.

The file specified by the lpNewFile parameter remains open until the system is restarted.

If hKey is a handle returned by RegConnectRegistry, then the paths specified in lpNewFile and lpOldFile are relative to the remote computer.

The calling process must have the SE_RESTORE_NAME and SE_BACKUP_NAME privileges on the computer in which the registry resides. For more information, see Running with Special Privileges.

Note

The winreg.h header defines RegReplaceKey as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

RegConnectRegistry

RegDeleteKey

RegLoadKey

RegRestoreKey

RegSaveKey

Registry Functions

Registry Overview