RegistryKey.ValueCount Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Recupera el recuento de valores de la clave.
public:
property int ValueCount { int get(); };
public int ValueCount { get; }
member this.ValueCount : int
Public ReadOnly Property ValueCount As Integer
Valor de propiedad
Número de pares nombre-valor en la clave.
Excepciones
El usuario no tiene permiso de lectura para la clave.
El RegistryKey objeto que se está manipulando está cerrado (no se puede acceder a las claves cerradas).
El usuario no tiene los derechos del Registro necesarios.
Se ha producido un error del sistema, por ejemplo, se ha eliminado la clave actual.
Ejemplos
Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la RegistryKey clase .
// Print the information from the Test9999 subkey.
Console::WriteLine( "There are {0} subkeys under Test9999.", test9999->SubKeyCount.ToString() );
array<String^>^subKeyNames = test9999->GetSubKeyNames();
for ( int i = 0; i < subKeyNames->Length; i++ )
{
RegistryKey ^ tempKey = test9999->OpenSubKey( subKeyNames[ i ] );
Console::WriteLine( "\nThere are {0} values for {1}.", tempKey->ValueCount.ToString(), tempKey->Name );
array<String^>^valueNames = tempKey->GetValueNames();
for ( int j = 0; j < valueNames->Length; j++ )
{
Console::WriteLine( "{0,-8}: {1}", valueNames[ j ], tempKey->GetValue( valueNames[ j ] )->ToString() );
}
}
// Print the information from the Test9999 subkey.
Console.WriteLine("There are {0} subkeys under {1}.",
test9999.SubKeyCount.ToString(), test9999.Name);
foreach(string subKeyName in test9999.GetSubKeyNames())
{
using(RegistryKey
tempKey = test9999.OpenSubKey(subKeyName))
{
Console.WriteLine("\nThere are {0} values for {1}.",
tempKey.ValueCount.ToString(), tempKey.Name);
foreach(string valueName in tempKey.GetValueNames())
{
Console.WriteLine("{0,-8}: {1}", valueName,
tempKey.GetValue(valueName).ToString());
}
}
}
' Print the information from the Test9999 subkey.
Console.WriteLine("There are {0} subkeys under Test9999.", _
test9999.SubKeyCount.ToString())
For Each subKeyName As String In test9999.GetSubKeyNames()
Dim tempKey As RegistryKey = _
test9999.OpenSubKey(subKeyName)
Console.WriteLine(vbCrLf & "There are {0} values for " & _
"{1}.", tempKey.ValueCount.ToString(), tempKey.Name)
For Each valueName As String In tempKey.GetValueNames()
Console.WriteLine("{0,-8}: {1}", valueName, _
tempKey.GetValue(valueName).ToString())
Next
Next
Comentarios
Cada clave del Registro tiene un valor predeterminado que no está asociado a ningún nombre. Este valor sin nombre se puede establecer mediante el SetValue método y especificando null o la cadena vacía ("") para name. Si el valor predeterminado nunca se ha establecido, no contribuye al recuento total devuelto por la ValueCount propiedad; una vez establecido, siempre se cuenta.