RegistryKey.SubKeyCount Vlastnost

Definice

Načte počet podklíčů aktuálního klíče.

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

Hodnota vlastnosti

Počet podklíčů aktuálního klíče.

Výjimky

Uživatel nemá oprávnění ke čtení klíče.

Manipulace RegistryKey je uzavřená (uzavřené klávesy nelze získat přístup).

Uživatel nemá potřebná práva registru.

Došlo k systémové chybě, například aktuální klíč byl odstraněn.

Příklady

Tento příklad kódu je součástí většího příkladu uvedeného pro třídu RegistryKey.

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

Poznámky

Tato vlastnost nerekurzivně počítá názvy. Vrátí pouze počet názvů na základní úrovni, ze které byl volána.

Platí pro

Viz také