读取注册表需要using Microsoft.Win32

读取指定路径的注册表,例如如下位置:

RegistryKey uninstall = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\MicroSoft\Windows\CurrentVersion\Uninstall");

从其子项中读取名称含“QQ”的子项

 1             RegistryKey uninstall = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\MicroSoft\Windows\CurrentVersion\Uninstall");
 2             foreach (string softKeyName in uninstall.GetSubKeyNames())
 3             {
 4                 if (softKeyName.Contains("QQ"))
 5                 {
 6                     lbResult.Items.Add(softKeyName);
 7                     RegistryKey soft = uninstall.OpenSubKey(softKeyName);
 8                     foreach (string valueName in soft.GetValueNames())
 9                     {
10                         lbResult.Items.Add(string.Format("    {0}:{1}", valueName, soft.GetValue(valueName).ToString()));
11                     }
12                 }
13             }

结果如下:

 

posted on 2016-12-13 17:22  今木。非昔木  阅读(618)  评论(0编辑  收藏  举报