注冊表子項有一個(默認)鍵值阱洪,如何設置和獲取官網(wǎng)的答案如下:
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);
// 創(chuàng)建子項
_appRegHandle.CreateSubKey("testsub");
// 打開子項
RegistryKey testKey = _appRegHandle.OpenSubKey("testsub",true);
// 設置(默認)值
testKey.SetValue("", "abc");
// 獲取(默認)值
string testValue = testkey.GetValue("").ToString();
testkey.Close();
_appRegHandle.Close();