key.DeleteSubKeyTree(childKey);
, выдается исключение, говорящее:
System.UnauthorizedAccessException: «Невозможно записать в реестр
ключ».
Это что я пытаюсь:
Код: Выделить всё
static void Main(string[] args)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
foreach (var childKey in key.GetSubKeyNames())
{
RegistryKey productKey = key.OpenSubKey(childKey);
if (productKey != null)
{
var keyValues = productKey.GetValueNames();
if (keyValues.Any(x => x.Equals("Publisher", StringComparison.OrdinalIgnoreCase)))
{
var value = productKey.GetValue("Publisher").ToString();
if (!string.IsNullOrWhiteSpace(value) && value.Equals("HCI", StringComparison.OrdinalIgnoreCase))
{
key.DeleteSubKeyTree(childKey);
return;
}
}
}
}
Console.ReadLine();
}

Подробнее здесь: https://stackoverflow.com/questions/793 ... sexception
Мобильная версия