注册表读取和写入

血红的双手。 提交于 2020-01-14 02:07:38

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();
}

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!