RegistryKey.GetValueNames Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera tablicę ciągów, która zawiera wszystkie nazwy wartości skojarzone z tym kluczem.
public:
cli::array <System::String ^> ^ GetValueNames();
public string[] GetValueNames();
member this.GetValueNames : unit -> string[]
Public Function GetValueNames () As String()
Zwraca
Tablica ciągów zawierająca nazwy wartości bieżącego klucza.
Wyjątki
Użytkownik nie ma uprawnień wymaganych do odczytu z klucza rejestru.
Manipulowanie RegistryKey jest zamykane (nie można uzyskać dostępu do zamkniętych kluczy).
Użytkownik nie ma niezbędnych praw rejestru.
Wystąpił błąd systemowy; na przykład bieżący klucz został usunięty.
Przykłady
Ten przykład kodu jest częścią większego przykładu udostępnionego dla klasy 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
Uwagi
Jeśli nie znaleziono nazw wartości klucza, zwracana jest pusta tablica.
Klucz rejestru może mieć wartość domyślną — czyli parę nazwa/wartość, w której nazwa jest pustym ciągiem (""). Jeśli dla klucza rejestru ustawiono wartość domyślną, tablica zwrócona przez GetValueNames metodę zawiera pusty ciąg.