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 

字段值

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/ME 还支持注册表,因此,应用程序可以访问用户特定的信息,其方式与在 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/ME 可以将此文件复制到用户的当前系统,以便设置可以通过用户从一台计算机移动到另一台计算机。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.

适用于