RegistryKey.SubKeyCount Propriedade

Definição

Recupera a contagem de subchaves da chave atual.

public:
 property int SubKeyCount { int get(); };
public int SubKeyCount { get; }
member this.SubKeyCount : int
Public ReadOnly Property SubKeyCount As Integer

Valor da propriedade

O número de subchaves da chave atual.

Exceções

O usuário não tem permissão de leitura para a chave.

O RegistryKey que está sendo manipulado é fechado (chaves fechadas não podem ser acessadas).

O usuário não tem os direitos do Registro necessários.

Ocorreu um erro de sistema, por exemplo, a chave atual foi excluída.

Exemplos

Este exemplo de código faz parte de um exemplo maior fornecido para a RegistryKey classe .

// 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

Comentários

Essa propriedade não conta nomes recursivamente. Ele retorna apenas a contagem de nomes no nível base do qual foi chamado.

Aplica-se a

Confira também