次の方法で共有


Registry.Users フィールド

既定のユーザー構成に関する情報を格納します。このフィールドには、Windows レジストリの基本キー HKEY_USERS が読み込まれます。

Public Shared ReadOnly Users As RegistryKey
[C#]
public static readonly RegistryKey Users;
[C++]
public: static RegistryKey* Users;
[JScript]
public static var Users : RegistryKey;

解説

このキーには、コンピュータの各ユーザーのブランチが格納されます。ローカル コンピュータの新しいユーザーに対して既定の構成が割り当てられます。ユーザーが設定を変更していない場合には、既定の現在のユーザーに対して既定の構成が割り当てられます。Windows 98/ME でも Registry.Users がサポートされているため、アプリケーションは Windows 2000 と同じ方法でユーザー固有の情報にアクセスできます。各ユーザーの情報は個別のファイルに格納されています。このファイルは、ローカル コンピュータまたはネットワーク サーバーに格納できます。Windows 98/ME では、ユーザー情報のファイルを各ユーザーの現在のシステムにコピーできます。このため、ユーザーがあるコンピュータから別のコンピュータに移動する場合、この移動先コンピュータにユーザー設定を移動できます。

使用例

[Visual Basic, C#, C++] このキーのサブキーを取得し、これらのサブキーの名前を画面に出力する方法の例を次に示します。必要な特定のサブキーのインスタンスを作成するには、 OpenSubKey メソッドを使用します。次に、 RegistryKey で別の演算を使用して、そのキーを操作します。

 
Imports System
Imports Microsoft.Win32

Class Reg
    
    Public Shared Sub Main()
        
        ' Create a RegistryKey, which will access the HKEY_USERS
        ' key in the registry of this machine.
        Dim rk As RegistryKey = Registry.Users
        
        ' 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

[C#] 
using System;
using Microsoft.Win32;

class Reg {
    public static void Main() {

        // Create a RegistryKey, which will access the HKEY_USERS
        // key in the registry of this machine.
        RegistryKey rk = Registry.Users;

        // 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;
        }
    }
}

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace Microsoft::Win32;

void PrintKeys(RegistryKey* rkey) {

    // Retrieve all the subkeys for the specified key.
    String* names[] = rkey->GetSubKeyNames();

    int icount = 0;

    Console::WriteLine(S"Subkeys of {0}", rkey->Name);
    Console::WriteLine(S"-----------------------------------------------");

    // Print the contents of the array to the console.
    System::Collections::IEnumerator* enum0 = names->GetEnumerator();
    while (enum0->MoveNext())
    {
        String* s = __try_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_USERS
    // key in the registry of this machine.
    RegistryKey* rk = Registry::Users;

    // Print out the keys.
    PrintKeys(rk);
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Registry クラス | Registry メンバ | Microsoft.Win32 名前空間