I've been playing around with the C++ registry functions, and I'm trying to get RegCopyTree working, but every time I try, I get an error like
ERROR_FILE_NOT_FOUND
or
ERROR_ACCESS_DENIED.
I am running the program as administrator, and all other registry functions work fine.
Here is the code I'm using:
HKEY destinationKey;
RegCreateKeyEx(getRootKeyFromCode(rootKeyCode),
destinationKeyPathNative, 0, NULL, 0, 0, NULL,
&destinationKey, NULL);
RegCopyTree(INSERT_ROOT_KEY_HERE,
INSERT_ORIGINAL_KEY_PATH_HERE, destinationKey);
RegCloseKey(destinationKey);
I've removed the error handling and some other irrelevant parts.
Destination key handle should have write access, to be able to copy to it. Calling RegCreateKeyEx()
without specifying access mode either fails or doesn't grant write access. Try with KEY_WRITE
or KEY_CREATE_SUB_KEY
as sixth argument.