Registry.ClassesRoot 字段

定义

定义文档的类型(或类)以及与那些类型关联的属性。Defines the types (or classes) of documents and the properties associated with those types. 该字段读取 Windows 注册表基项 HKEY_CLASSES_ROOT。This field reads the Windows registry base key HKEY_CLASSES_ROOT.

public: static initonly Microsoft::Win32::RegistryKey ^ ClassesRoot;
public static readonly Microsoft.Win32.RegistryKey ClassesRoot;
 staticval mutable ClassesRoot : Microsoft.Win32.RegistryKey
Public Shared ReadOnly ClassesRoot 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_CLASSES_ROOT
   // key in the registry of this machine.
   RegistryKey ^ rk = Registry::ClassesRoot;
   
   // 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_CLASSES_ROOT
        // key in the registry of this machine.
        RegistryKey rk = Registry.ClassesRoot;

        // 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_CLASSES_ROOT
        ' key in the registry of this machine.
        Dim rk As RegistryKey = Registry.ClassesRoot
        
        ' 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

注解

常规应用程序和 OLE 应用程序使用此项下存储的数据。Both conventional applications and OLE applications use data that is stored under this key. 此密钥还可以提供向后的兼容性 Windows 3.1 注册数据库存储 DDE 和 OLE 支持的信息。This key also provides backward compatibility with the Windows 3.1 registration database by storing information for DDE and OLE support. 文件查看器和用户界面扩展将其 OLE 类标识符存储在此项,并在此注册表注册处理服务器。File viewers and user interface extensions store their OLE class identifiers in this key, and processing servers are registered in this key.

适用于