码迷,mamicode.com
首页 > 其他好文 > 详细

注册表读取和写入

时间:2020-01-14 10:06:05      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:创建   null   oid   读取   set   get   registry   current   名称   

static void Main(string[] args)
{
RegistryKey regkey = Registry.CurrentUser.OpenSubKey("cc");
if (regkey != null)
{
Console.WriteLine(regkey.GetValue("UserName").ToString());//读取注册表
regkey.Close();
}
Console.ReadKey();
}
//创建和写入注册表
private static void Test()
{
RegistryKey regkey = Registry.CurrentUser.CreateSubKey("cc");//"cc"要取一个特殊的字符串,防止与系统或其他程序写注册表名称相同,
??????????? regkey.SetValue("UserName", "cwx776534");
regkey.Close();
}

注册表读取和写入

标签:创建   null   oid   读取   set   get   registry   current   名称   

原文地址:https://www.cnblogs.com/zhujie-com/p/12190115.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!