views:

22

answers:

1

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?

+1  A: 

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.

Steve Townsend