Registry.CurrentUser Pole
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Obsahuje informace o aktuálních uživatelských předvolbách. Toto pole načte základní HKEY_CURRENT_USER Windows registru.
public: static initonly Microsoft::Win32::RegistryKey ^ CurrentUser;
public static readonly Microsoft.Win32.RegistryKey CurrentUser;
staticval mutable CurrentUser : Microsoft.Win32.RegistryKey
Public Shared ReadOnly CurrentUser As RegistryKey
Hodnota pole
Příklady
Následující příklad ukazuje, jak načíst podklíče tohoto klíče a vytisknout jejich názvy na obrazovku. Použijte metodu OpenSubKey k vytvoření instance konkrétního podklíče zájmu. K manipulaci s tímto klíčem pak můžete použít jiné operace RegistryKey .
using namespace System;
using namespace Microsoft::Win32;
void PrintKeys( RegistryKey ^ rkey )
{
// Retrieve all the subkeys for the specified key.
array<String^>^names = rkey->GetSubKeyNames();
int icount = 0;
Console::WriteLine( "Subkeys of {0}", rkey->Name );
Console::WriteLine( "-----------------------------------------------" );
// Print the contents of the array to the console.
System::Collections::IEnumerator^ enum0 = names->GetEnumerator();
while ( enum0->MoveNext() )
{
String^ s = safe_cast<String^>(enum0->Current);
Console::WriteLine( s );
// The following code puts a limit on the number
// of keys displayed. Comment it out to print the
// complete list.
icount++;
if ( icount >= 10 )
break;
}
}
int main()
{
// Create a RegistryKey, which will access the HKEY_CURRENT_USER
// key in the registry of this machine.
RegistryKey ^ rk = Registry::CurrentUser;
// Print out the keys.
PrintKeys( rk );
}
using System;
using Microsoft.Win32;
class Reg {
public static void Main() {
// Create a RegistryKey, which will access the HKEY_CURRENT_USER
// key in the registry of this machine.
RegistryKey rk = Registry.CurrentUser;
// Print out the keys.
PrintKeys(rk);
}
static void PrintKeys(RegistryKey rkey) {
// Retrieve all the subkeys for the specified key.
string [] names = rkey.GetSubKeyNames();
int icount = 0;
Console.WriteLine("Subkeys of " + rkey.Name);
Console.WriteLine("-----------------------------------------------");
// Print the contents of the array to the console.
foreach (string s in names) {
Console.WriteLine(s);
// The following code puts a limit on the number
// of keys displayed. Comment it out to print the
// complete list.
icount++;
if (icount >= 10)
break;
}
}
}
Imports Microsoft.Win32
Class Reg
Public Shared Sub Main()
' Create a RegistryKey, which will access the HKEY_CURRENT_USER
' key in the registry of this machine.
Dim rk As RegistryKey = Registry.CurrentUser
' Print out the keys.
PrintKeys(rk)
End Sub
Shared Sub PrintKeys(rkey As RegistryKey)
' Retrieve all the subkeys for the specified key.
Dim names As String() = rkey.GetSubKeyNames()
Dim icount As Integer = 0
Console.WriteLine("Subkeys of " & rkey.Name)
Console.WriteLine("-----------------------------------------------")
' Print the contents of the array to the console.
Dim s As String
For Each s In names
Console.WriteLine(s)
' The following code puts a limit on the number
' of keys displayed. Comment it out to print the
' complete list.
icount += 1
If icount >= 10 Then
Exit For
End If
Next s
End Sub
End Class
Poznámky
Informace uložené v tomto klíči zahrnují nastavení proměnných prostředí a dat o skupinách programů, barvách, tiskárnách, síťových připojeních a předvolbách aplikací. Tento klíč usnadňuje vytvoření nastavení aktuálního uživatele. V tomto klíči dodavatelé softwaru ukládají aktuální předvolby specifické pro uživatele, které se mají používat v rámci svých aplikací. Microsoft například vytvoří klíč HKEY_CURRENT_USER\Software\Microsoft pro své aplikace, který bude používat, přičemž každá aplikace vytvoří vlastní podklíč pod klíčem Microsoft.