将开发过程经常用的代码片段珍藏起来,如下代码段是关于C#读取windows注册表键值的代码。

using Microsoft.Win32;

 




读取注册表代码


RegistryKey masterKey = Registry.LocalMachine.CreateSubKey
("SOFTWARE\Test\Preferences");
if (masterKey == null)
{
Console.WriteLine ("Null Masterkey!");
}
else
{
Console.WriteLine ("MyKey = {0}", masterKey.GetValue ("MyKey"));
}
masterKey.Close();




 

posted on 2021-10-23 14:21  odsxe  阅读(104)  评论(0编辑  收藏  举报