简体   繁体   English

如何以编程方式在 .net 备份中或还原 regedit 节点?

[英]how can I programmatically in .net backup or restore a regedit node?

I store (ie. persist) my app's settings in regedit, and want to be able to save them in a file, and restore later.我在 regedit 中存储(即持久化)我的应用程序设置,并希望能够将它们保存在一个文件中,并在以后恢复。

How can I store everything in a specific regedit node (little yellow folder on the left)?如何将所有内容存储在特定的 regedit 节点(左侧的小黄色文件夹)中? 在此处输入图片说明

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.您可以使用 regedit.exe 将其导出为 reg 文件进行备份,并使用该文件进行恢复。

Example to export subkeys to a reg file将子项导出到 reg 文件的示例

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或者使用 P/Invoke 调用 RegSaveKey 和 RegRestoreKey 来执行此操作

https://www.codeproject.com/Articles/7874/%2FArticles%2F7874%2FHow-to-Save-and-Restore-Registry-Keys 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.或者使用 .Net Framework Microsoft.Win32.Registry 将值读取和写入不同的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM