RegistryKey.SubKeyCount 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取目前機碼中子機碼的計數。
public:
property int SubKeyCount { int get(); };
public int SubKeyCount { get; }
member this.SubKeyCount : int
Public ReadOnly Property SubKeyCount As Integer
屬性值
目前機碼的子機碼數目。
例外狀況
使用者不具有機碼的讀取權限。
正接受管理的 RegistryKey 已經關閉 (關閉的機碼無法存取)。
使用者沒有必要的登錄權限。
發生系統錯誤,例如,目前的機碼已經刪除。
範例
此程式代碼範例是提供給 類別之較大範例的 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
備註
此屬性不會遞歸計算名稱。 它只會傳回其呼叫來源基底層級上的名稱計數。