Share via


Registry.ClassesRoot 필드

정의

해당 형식과 관련된 속성 및 문서의 형식 또는 클래스를 정의합니다. 이 필드는 Windows 레지스트리 기본 키 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 

필드 값

예제

다음 예제에서는 이 키의 하위 키를 검색하고 해당 이름을 화면에 출력하는 방법을 보여 줍니다. 메서드를 OpenSubKey 사용하여 관심 있는 특정 하위 키의 instance 만듭니다. 그런 다음 의 RegistryKey 다른 작업을 사용하여 해당 키를 조작할 수 있습니다.

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 애플리케이션에는이 키 아래에 저장 된 데이터를 사용 합니다. 또한 이 키는 DDE 및 OLE 지원에 대한 정보를 저장하여 Windows 3.1 등록 데이터베이스와의 이전 버전과의 호환성을 제공합니다. 파일 뷰어 및 사용자 인터페이스 확장은 OLE 클래스 식별자를 이 키에 저장하고 처리 서버는 이 키에 등록됩니다.

적용 대상