Registry.CurrentUser フィールド

定義

現在のユーザー設定に関する情報が格納されます。 このフィールドには、Windows レジストリの基本キー 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 

フィールド値

次の例では、このキーのサブキーを取得し、その名前を画面に出力する方法を示します。 メソッドを OpenSubKey 使用して、目的の特定のサブキーのインスタンスを作成します。 その後、 で他の 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

注釈

このキーに格納される情報には、環境変数の設定と、プログラム グループ、色、プリンター、ネットワーク接続、アプリケーションの基本設定に関するデータが含まれます。 このキーを使用すると、現在のユーザーの設定を簡単に確立できます。 このキーでは、ソフトウェア ベンダーは、アプリケーション内で使用する現在のユーザー固有の基本設定を格納します。 たとえば、Microsoftは、アプリケーションで使用するHKEY_CURRENT_USER\Software\Microsoft キーを作成し、各アプリケーションで Microsoft キーの下に独自のサブキーを作成します。

適用対象