SHCopyKey function
Applies to: desktop apps only
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 SHCopyKey( __in HKEY hkeySrc, __in_opt LPCTSTR pszSrcSubKey, __in HKEY hkeyDest, __reserved DWORD fReserved );
Parameters
- hkeySrc [in]
-
Type: HKEY
A handle to the source key (for example, HKEY_CURRENT_USER).
- pszSrcSubKey [in, optional]
-
Type: LPCTSTR
The subkey whose subkeys and values are to be copied.
- hkeyDest [in]
-
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.
Requirements
|
Minimum supported client | Windows 2000 Professional, Windows XP |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | SHCopyKeyW (Unicode) and SHCopyKeyA (ANSI) |
Send comments about this topic to Microsoft
Build date: 3/7/2012
::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Classes\\CLSID", 0, KEY_WOW64_32KEY|KEY_READ, &hkSource))
::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Classes\\CLSID", 0, KEY_WOW64_64KEY|KEY_WRITE, &hkDest))
::SHCopyKey(hkSource, L"{DC6EFB56-9CFA-464D-8880-44885D7DC193}", hkDest, NULL);
(Error checking removed for brevity.)
That should copy the CLSID from the 32-bit registry area to the 64-bit registry area; however, while it returns success it doesn't appear to do anything.
(This was tested within a 32-bit app. Haven't tried from a 64-bit app, but it shouldn't make any difference as using KEY_WOW64_xxKEY should allow either type of app to view both registry areas.)
- 1/25/2010
- Leo Davidson
- 1/25/2010
- Leo Davidson