Registry.CurrentUser Campo

Definição

Contém informações sobre as preferências do usuário atual.Contains information about the current user preferences. Este campo lê a chave base de Registro HKEY_CURRENT_USER do Windows.This field reads the Windows registry base key HKEY_CURRENT_USER.

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 

Valor do campo

RegistryKey

Exemplos

O exemplo a seguir demonstra como recuperar as subchaves dessa chave e imprime seus nomes na tela.The following example demonstrates how to retrieve the subkeys of this key, and prints their names to the screen. Use o OpenSubKey método para criar uma instância da subchave de interesse específica.Use the OpenSubKey method to create an instance of the particular subkey of interest. Você pode usar outras operações no RegistryKey para manipular essa chave.You can then use other operations in RegistryKey to manipulate that key.

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

Comentários

As informações armazenadas nessa chave incluem as configurações de variáveis de ambiente e dados sobre grupos de programas, cores, impressoras, conexões de rede e preferências de aplicativo.Information stored in this key includes the settings of environment variables and data about program groups, colors, printers, network connections, and application preferences. Essa chave torna mais fácil estabelecer as configurações do usuário atual.This key makes it easier to establish the current user's settings. Nessa chave, os fornecedores de software armazenam as preferências atuais específicas do usuário a serem usadas em seus aplicativos.In this key, software vendors store the current user-specific preferences to be used within their applications. A Microsoft, por exemplo, cria a chave de HKEY_CURRENT_USER\Software\Microsoft para que seus aplicativos usem, com cada aplicativo criando sua própria subchave na chave da Microsoft.Microsoft, for example, creates the HKEY_CURRENT_USER\Software\Microsoft key for its applications to use, with each application creating its own subkey under the Microsoft key.

Aplica-se a