Ya he analizado los temas existentes, así que intente no incluir enlaces aquí.Obtiene el valor de la clave de registro C#
Quiero obtener el valor de una clave de registro, simple y llana. Esto es lo que tengo hasta ahora.
Registro: 1) hizo una llave bajo
CURRENT_USER \ Software \ Custom_Subkey \ custom_value \ custom_key \ valor_cadena
Estoy tratando de encontrar la valor_cadena
string reg_subKey = "Software\\Custom_Subkey\\Custom_Value";
RegistryKey root = Registry.CurrentUser.CreateSubKey(reg_subKey);
foreach (string keyname in root.GetValueNames())
{
textBox4.AppendText(keyname.ToString() + Environment.NewLine);
// Appends the following data to textBox4 once the foreach is completed:
// Header1
// Header2
// Header3
// Header4
// Header5
// Now I want to get the VALUES of each header:
using (RegistryKey key = root.OpenSubKey(keyname))
{
**// THIS LINE GETS HIGHLIGHTED WITH THE FOLLOWING ERROR:
"Object reference not set to an instance of an object.**"
MessageBox.Show(key.ValueCount.ToString());
}
}
Hopefu lly esto es una solución simple. Espero escuchar sus respuestas. Gracias, Evan
'root.OpenSubKey (nombre clave)' está devolviendo nulo. Es por eso que obtienes ese error. – Hogan
¿No es ese el código correcto entonces? Estoy asumiendo ... ¿Hay alguna otra forma de abrir la llave? –
De los documentos " Si no se puede encontrar la subclave especificada, se devuelve null". – Hogan