public static void CleanSubSettings(Guid pluginGuid, List<string> toKeep) { string subKey = string.Format(@"{0}\Plugins\{1}", pGinaRoot, pluginGuid.ToString()); using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKey, true)) { if (key != null) { string[] names = key.GetSubKeyNames(); foreach (string n in names) { if (! toKeep.Contains(n)) { key.DeleteSubKey(n, false); } } } } }