如何在不运行 Regedit 的情况下读取和导出 Windows 注册表的子树?

发布于 2024-09-30 10:40:24 字数 412 浏览 0 评论 0原文

我有一个 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 技术交流群。

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

发布评论

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

评论(1

红玫瑰 2024-10-07 10:40:24

没有单一的 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.

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