如何在不运行 Regedit 的情况下读取和导出 Windows 注册表的子树?
我有一个 32 位 C++ 程序,可以收集诊断数据以帮助对我们的软件进行故障排除。我希望它导出注册表的某个子树 - 类似于:
regedit.exe /e ExportResult.reg HKEY_LOCAL_MACHINE\SubTreeIWantToExport
问题是 Regedit 可能需要在 Vista 及更高版本上提升权限,而运行我的程序的用户可能没有足够的权限,但可能有足够的权限从该子树中读取。我还预见到 64 位系统上的 SysWOW64 会出现一些微妙的问题。因此运行 Regedit 是一个糟糕的选择。
当然,我的程序可以读取注册表本身并以某种方式生成相当于 .reg 文件的文件,但实现该功能将是重新发明轮子。
是否有其他方法可以从我的程序中读取和导出 Windows 注册表子树?
I have a 32-bit C++ program that gathers diagnostic data to help troubleshoot our software. I'd like it to export a certain subtree of the registry - something like:
regedit.exe /e ExportResult.reg HKEY_LOCAL_MACHINE\SubTreeIWantToExport
The problem is Regedit will likely require priviledges elevation on Vista and above and the user running my program might not have enough rights for that but will likely have enough rights to read from that subtree. Also I foresee subtle problems with SysWOW64 on 64-bit systems. So running Regedit is a bad option.
Of course my program could read the registry itself and somehow produce an equivalent of a .reg file but implementing that functionality would be reinventing the wheel.
Is there some other way to read and export a Windows registry subtree from my program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有单一的 Win32 或 .Net API 来执行注册表导出/导入。
你可以这样做 this 但我认为你的要求是避免暴力破解。但是,您可能提出的任何解决方案都需要基于底层 Win32 API 进行构建,
regedit
也是如此。There is no single-shot Win32 or .Net API to do registry export/import.
You could do it something like this but I think your requirements are to avoid brute force. However, any solution you might come up with requires building on the underlying Win32 APIs, as does
regedit
.