You’re giving in to reading permission as the function requires? If you prefer another way to obtain and change this data, you can use the class methods RegistryKey
for that reason.
To recover a value you can use the method GetValue()
.
const string REG_KEY_NAME = @"SOFTWARE\Bar\Baz";
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(REG_KEY_NAME, false)) // Abrir a key para leitura
{
string Valor = key.GetValue("NomeDoValor").ToString();
}
To change a value or data, you can use the method SetValue()
.
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(REG_KEY_NAME, true)) // Abrir a key para leitura/gravação
{
key.SetValue("NomeDoValor", "FooBar");
}
I put in the Github for future reference.