使用 RegCreateKeyEx 给出错误代码 5
我在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在
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 inHKEY_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.