Registry.ClassesRoot Field


Defines the types (or classes) of documents and the properties associated with those types. This field reads the Windows registry base key HKEY_CLASSES_ROOT.

Namespace:   Microsoft.Win32
Assembly:  mscorlib (in mscorlib.dll)

public static readonly RegistryKey ClassesRoot

Field Value

Type: Microsoft.Win32.RegistryKey

Both conventional applications and OLE applications use data that is stored under this key. This key also provides backward compatibility with the Windows 3.1 registration database by storing information for DDE and OLE support. File viewers and user interface extensions store their OLE class identifiers in this key, and processing servers are registered in this key.

The following example demonstrates how to retrieve the subkeys of this key, and prints their names to the screen. Use the OpenSubKey method to create an instance of the particular subkey of interest. You can then use other operations in RegistryKey to manipulate that key.

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.

    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);

        // Print the contents of the array to the console.
        foreach (String s in names) {

            // The following code puts a limit on the number
            // of keys displayed.  Comment it out to print the
            // complete list.
            if (icount >= 10)

.NET Framework
Available since 1.1
Return to top