开发者

How do I read and export a subtree of Windows registry without running Regedit?

开发者 https://www.devze.com 2023-01-22 18:52 出处:网络
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:

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消