设置注册表子项的(默认)值

注册表子项有一个(默认)键值,如何设置和获取官网的答案如下:

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();
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,136评论 0 10
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 7,938评论 0 0
  • 不知不觉,从今天起正式奔三了,老公说:“奔三了,四还会远吗?”听他这么一说,其实是在感叹时光的流逝过快,于我而言,...
    茉念花开阅读 1,306评论 0 0
  • 在漫长的生活岁月中能够保持效能的所有人,几乎都和我一样在不断地学习。无论是企业主管还是学者,无论是军队的高级将领还...
    肥肉666阅读 955评论 0 0
  • 松兰山忆人 春浪薄纱软,轻鸥帆影远。 蒹葭海畔生,礁上听风懒。 最忆是何人,坐看清且婉。 于此复相思,如潮次第满。...
    胡清隐阅读 4,132评论 0 0