-1

I store (ie. persist) my app's settings in regedit, and want to be able to save them in a file, and restore later.

How can I store everything in a specific regedit node (little yellow folder on the left)? enter image description here

Doug Null
  • 7,989
  • 15
  • 69
  • 148
  • 1
    Regedit is a tool to access the registry. So you're not storing things in regedit, you're storing them in the registry. That might help search for answers. From a quick look https://www.c-sharpcorner.com/UploadFile/f9f215/windows-registry/ seems to answer your question. – Ben Jan 21 '19 at 22:37
  • The, possibly, simplest way is using a predefined utility, `reg.exe`. You can start it with `Process.Start()`. To see what it does, open a `cmd.exe` prompt and enter `REG /?`. You can call it from your app without a visible console window, setting up the `ProcessStartInfo` with `.CreateNoWindow = true.` – Jimi Jan 21 '19 at 22:51

1 Answers1

0

There are several ways to do this. You can use regedit.exe to export it to a reg file for backup and use the file for restoring purpose.

Example to export subkeys to a reg file

regedit.exe /e c:\temp\out.reg "HKEY_CURRENT_USER\Software\Microsoft\InputPersonalization"

Or use P/Invoke to call RegSaveKey and RegRestoreKey to do this

https://www.codeproject.com/Articles/7874/%2FArticles%2F7874%2FHow-to-Save-and-Restore-Registry-Keys

Or use .Net Framework Microsoft.Win32.Registry to read and write values to a different file.

OKEEngine
  • 888
  • 11
  • 28