使用 RegCreateKeyEx 给出错误代码 5

发布于 2024-12-08 14:50:41 字数 390 浏览 2 评论 0原文

我在 64 位 Windows 中使用了 win32 应用程序(VisualStudio 2008)中的 RegCreateKeyEx(使用目标 x64 构建的项目)。它能够创建一个注册表项。现在我有一个 dll 文件(使用目标 x64 构建的项目),它也想创建注册表项,但我的 dll 返回错误代码 5(是的!它是访问被拒绝的标志)。我的 samDesired 标志具有 KEY_ALL_Access + 在链接器->清单文件->以管理员身份运行中选择,但仍然失败,错误代码为 5。而它在 32 位 Windows 中完美运行(项目使用目标 x86 构建)。我错过了什么吗? 注意:我正在尝试在 HKEY_LOCAL_MACHINE 中创建一个条目。

I used RegCreateKeyEx from a win32 application(VisualStudio 2008) in 64 bit windows(Project built with target x64). It was able to create a registry entry. Now I have a dll file (Project built with target x64) which too wanna create registry entry but my dll is returning error code 5(Yeah! its a sign of access denied). My samDesired flag have KEY_ALL_Access + In linker->manifestfile->run as administrator chosen which still fails with error code 5. Whereas it works perfectly in 32bit windows(Project built with target x86). Am i missing something?
NOTE: I'm trying to create an entry at HKEY_LOCAL_MACHINE.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九厘米的零° 2024-12-15 14:50:41

您无法在 HKEY_LOCAL_MACHINE 中创建注册表项,因为这不是配置单元。您需要将密钥放入 HKEY_LOCAL_MACHINE\Software 或(不太可能)其他配置单元之一。

我不知道为什么当您在 WOW64 中运行 32 位代码时这似乎起作用,也许这是 32 位注册表视图呈现方式的副作用。

You can't create a registry key in HKEY_LOCAL_MACHINE because this isn't a hive. You need to put your key in HKEY_LOCAL_MACHINE\Software or (less probably) one of the other hives.

I don't know why this appeared to work when you were running 32-bit code in WOW64, perhaps this is a side-effect of the way the 32-bit view of the registry is presented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文