Checho Checho - 2 months ago 30
C Question

Save as .REG file using WinApi

I thought using RegSaveKeyEx would help me to save a registry subkey as a .REG file, but it is not working. I have this code:

// Saving key
LONG saveKey = RegSaveKeyExW(keyResult, L"C:\\Demo1.reg", securityAttributes, Flags);

is set as
, and
, as

I don't have any problem by saving it as a .DAT file, but want a .REG one, like exporting the subkey from the Registry window itself.

This is how the .REG file looks like:

.REG file

Not that I am not talking about enabling or disabling privileges in the access token, but using the function itself.


There is no Registry API function that will output a key in .reg format. You will have to enumerate the key's content yourself and write out your own .reg file manually.