读取注册表

读取注册表需要using Microsoft.Win32

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

RegistryKey uninstall = Registry.LocalMachine.OpenSubKey(@"SOFTWAREWOW6432NodeMicroSoftWindowsCurrentVersionUninstall");

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

 1             RegistryKey uninstall = Registry.LocalMachine.OpenSubKey(@"SOFTWAREWOW6432NodeMicroSoftWindowsCurrentVersionUninstall");
 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             }

结果如下:

原文地址:https://www.cnblogs.com/CinYung/p/6170757.html