注册表子项有一个(默认)键值,如何设置和获取官网的答案如下:
Note
A registry key can have one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To set this unnamed value, specify either null or the empty string ("") for name.
示例
RegistryKey _appRegHandle;
_appRegHandle = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\MyApp", true);
// 创建子项
_appRegHandle.CreateSubKey("testsub");
// 打开子项
RegistryKey testKey = _appRegHandle.OpenSubKey("testsub",true);
// 设置(默认)值
testKey.SetValue("", "abc");
// 获取(默认)值
string testValue = testkey.GetValue("").ToString();
testkey.Close();
_appRegHandle.Close();