Registry.Users 字段

定义

包含有关默认用户配置的信息。Contains information about the default user configuration. 该字段读取 Windows 注册表基项 HKEY_USERS。This field reads the Windows registry base key HKEY_USERS.

public: static initonly Microsoft::Win32::RegistryKey ^ Users;
public static readonly Microsoft.Win32.RegistryKey Users;
 staticval mutable Users : Microsoft.Win32.RegistryKey
Public Shared ReadOnly Users As RegistryKey 

字段值

示例

下面的示例演示如何检索此项的子项,并将其名称在屏幕上的打印。The following example demonstrates how to retrieve the subkeys of this key, and prints their names to the screen. 使用OpenSubKey方法来创建感兴趣的特定子项的一个实例。Use the OpenSubKey method to create an instance of the particular subkey of interest. 然后,可以使用中的其他操作RegistryKey来操作该注册表项。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_USERS
   // key in the registry of this machine.
   RegistryKey ^ rk = Registry::Users;
   
   // 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_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;
        }
    }
}
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

注解

此密钥包含为每个用户的计算机的分支。This key contains a branch for each user of the computer. 默认配置被提供本地计算机上为新用户并为默认值当前用户,如果用户未更改首选项。The default configuration is supplied for new users on the local computer and for the default current user if the user has not changed preferences. 因为 Windows 98 / 我还支持 Registry.Users,应用程序可以在它们在 Windows 2000 的相同方式访问特定于用户的信息。Because Windows 98/ME also supports Registry.Users, applications can access the user-specific information the same way they do under Windows 2000. 每个用户的信息存储在单独的文件,可以存储在本地或网络服务器上。Each user's information is stored in a separate file, which can be stored locally or on a network server. Windows 98 / 我可以将此文件复制到用户的当前系统,以便设置可以在一台计算机之间移动使用的用户。Windows 98/ME can copy this file to the user's current system so that settings can move from one computer to another with the user.

适用于