本文介绍了如何使用 RegCopyTree的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩 C++ 注册表函数,我试图让 RegCopyTree 正常工作,但每次尝试时,我都会收到类似的错误

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

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.

推荐答案

目标键句柄应该有写权限,才能复制到它.在不指定访问模式的情况下调用 RegCreateKeyEx() 要么失败,要么不授予写访问权限.尝试使用 KEY_WRITEKEY_CREATE_SUB_KEY 作为第六个参数.

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.

这篇关于如何使用 RegCopyTree的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 12:36