RegistryKey.GetValueNames Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Recupera una matrice di stringhe che contiene tutti i nomi di valore associati a questa chiave.
public:
cli::array <System::String ^> ^ GetValueNames();
public string[] GetValueNames();
member this.GetValueNames : unit -> string[]
Public Function GetValueNames () As String()
Valori restituiti
Matrice di stringhe che contiene i nomi di valore per la chiave corrente.
Eccezioni
L'utente non dispone delle autorizzazioni necessarie per leggere dalla chiave del Registro di sistema.
L'oggetto RegistryKey modificato è chiuso (non è possibile accedere alle chiavi chiuse).
L'utente non dispone dei diritti del Registro di sistema necessari.
Si è verificato un errore di sistema; Ad esempio, la chiave corrente è stata eliminata.
Esempio
Questo esempio di codice fa parte di un esempio più ampio fornito per la 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
Commenti
Se non vengono trovati nomi di valore per la chiave, viene restituita una matrice vuota.
Una chiave del Registro di sistema può avere un valore predefinito, ovvero una coppia nome/valore in cui il nome è la stringa vuota (""). Se per una chiave del Registro di sistema è stato impostato un valore predefinito, la matrice restituita dal GetValueNames metodo include la stringa vuota.