Checho Checho - 24 days ago 18
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);


securityAttributes
is set as
NULL
, and
Flags
, as
REG_LATEST_FORMAT
.

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.

Answer

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.

Comments