SHCopyKeyW function (shlwapi.h)

Recursively copies the subkeys and values of the source subkey to the destination key. SHCopyKey does not copy the security attributes of the keys.

Syntax

LSTATUS SHCopyKeyW(
  [in]           HKEY    hkeySrc,
  [in, optional] LPCWSTR pszSrcSubKey,
  [in]           HKEY    hkeyDest,
                 DWORD   fReserved
);

Parameters

[in] hkeySrc

Type: HKEY

A handle to the source key (for example, HKEY_CURRENT_USER).

[in, optional] pszSrcSubKey

Type: LPCTSTR

The subkey whose subkeys and values are to be copied.

[in] hkeyDest

Type: HKEY

The destination key.

fReserved

Type: DWORD

Reserved. Must be 0.

Return value

Type: LSTATUS

Returns ERROR_SUCCESS if successful, or one of the nonzero error codes defined in Winerror.h otherwise. Use FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag to retrieve a generic description of the error.

Remarks

Important  This function does not duplicate the security attributes of the keys and values that it copies. Rather, all security attributes in the destination key are the default attributes.
 

Note

The shlwapi.h header defines SHCopyKey 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.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 5.0 or later)