RegistryKey.CreateSubKey Metodo

Definizione

Crea una nuova sottochiave o apre una sottochiave esistente.

Overload

Nome Descrizione
CreateSubKey(String)

Crea una nuova sottochiave o apre una sottochiave esistente per l'accesso in scrittura.

CreateSubKey(String, RegistryKeyPermissionCheck)

Crea una nuova sottochiave o apre una sottochiave esistente per l'accesso in scrittura, usando l'opzione di controllo delle autorizzazioni specificata.

CreateSubKey(String, Boolean)

Crea una nuova sottochiave o apre una sottochiave esistente con l'accesso specificato. Disponibile a partire da .NET Framework 4.6.

CreateSubKey(String, RegistryKeyPermissionCheck, RegistrySecurity)

Crea una nuova sottochiave o apre una sottochiave esistente per l'accesso in scrittura, usando l'opzione di controllo delle autorizzazioni specificata e la sicurezza del Registro di sistema.

CreateSubKey(String, Boolean, RegistryOptions)

Crea una nuova sottochiave o apre una sottochiave esistente con l'accesso specificato. Disponibile a partire da .NET Framework 4.6.

CreateSubKey(String, RegistryKeyPermissionCheck, RegistryOptions)

Crea una sottochiave o apre una sottochiave per l'accesso in scrittura, usando le opzioni specificate per il controllo delle autorizzazioni e il Registro di sistema.

CreateSubKey(String, RegistryKeyPermissionCheck, RegistryOptions, RegistrySecurity)

Crea una sottochiave o apre una sottochiave per l'accesso in scrittura, usando l'opzione di controllo delle autorizzazioni, l'opzione del Registro di sistema e la sicurezza del Registro di sistema specificati.

CreateSubKey(String)

Origine:
RegistryKey.cs

Crea una nuova sottochiave o apre una sottochiave esistente per l'accesso in scrittura.

public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey);
member this.CreateSubKey : string -> Microsoft.Win32.RegistryKey
Public Function CreateSubKey (subkey As String) As RegistryKey

Parametri

subkey
String

Nome o percorso della sottochiave da creare o aprire. Questa stringa non fa distinzione tra maiuscole e minuscole.

Valori restituiti

Sottochiave appena create o null se l'operazione non è riuscita. Se viene specificata una stringa di lunghezza zero per subkey, viene restituito l'oggetto corrente RegistryKey .

Eccezioni

subkey è null.

L'utente non dispone delle autorizzazioni necessarie per creare o aprire la chiave del Registro di sistema.

L'oggetto RegistryKey su cui viene richiamato questo metodo viene chiuso (non è possibile accedere alle chiavi chiuse).

Impossibile RegistryKey scrivere in . Ad esempio, non è stato aperto come chiave scrivibile oppure l'utente non dispone dei diritti di accesso necessari.

Il livello di annidamento supera 510.

oppure

Si è verificato un errore di sistema, ad esempio l'eliminazione della chiave o un tentativo di creare una chiave nella LocalMachine radice.

Esempio

Nell'esempio di codice seguente viene illustrato come creare una sottochiave in HKEY_CURRENT_USER, modificarne il contenuto e quindi eliminare la sottochiave.

using namespace System;
using namespace System::Security::Permissions;
using namespace Microsoft::Win32;

int main()
{
   // Create a subkey named Test9999 under HKEY_CURRENT_USER.
   RegistryKey ^ test9999 = Registry::CurrentUser->CreateSubKey( "Test9999" );

   // Create two subkeys under HKEY_CURRENT_USER\Test9999.
   test9999->CreateSubKey( "TestName" )->Close();
   RegistryKey ^ testSettings = test9999->CreateSubKey( "TestSettings" );

   // Create data for the TestSettings subkey.
   testSettings->SetValue( "Language", "French" );
   testSettings->SetValue( "Level", "Intermediate" );
   testSettings->SetValue( "ID", 123 );
   testSettings->Close();

   // Print the information from the Test9999 subkey.
   Console::WriteLine( "There are {0} subkeys under Test9999.", test9999->SubKeyCount.ToString() );
   array<String^>^subKeyNames = test9999->GetSubKeyNames();
   for ( int i = 0; i < subKeyNames->Length; i++ )
   {
      RegistryKey ^ tempKey = test9999->OpenSubKey( subKeyNames[ i ] );
      Console::WriteLine( "\nThere are {0} values for {1}.", tempKey->ValueCount.ToString(), tempKey->Name );
      array<String^>^valueNames = tempKey->GetValueNames();
      for ( int j = 0; j < valueNames->Length; j++ )
      {
         Console::WriteLine( "{0,-8}: {1}", valueNames[ j ], tempKey->GetValue( valueNames[ j ] )->ToString() );

      }
   }
   
   // Delete the ID value.
   testSettings = test9999->OpenSubKey( "TestSettings", true );
   testSettings->DeleteValue( "id" );

   // Verify the deletion.
   Console::WriteLine( dynamic_cast<String^>(testSettings->GetValue(  "id", "ID not found." )) );
   testSettings->Close();

   // Delete or close the new subkey.
   Console::Write( "\nDelete newly created registry key? (Y/N) " );
   if ( Char::ToUpper( Convert::ToChar( Console::Read() ) ) == 'Y' )
   {
      Registry::CurrentUser->DeleteSubKeyTree( "Test9999" );
      Console::WriteLine( "\nRegistry key {0} deleted.", test9999->Name );
   }
   else
   {
      Console::WriteLine( "\nRegistry key {0} closed.", test9999->ToString() );
      test9999->Close();
   }
}
using System;
using System.Security.Permissions;
using Microsoft.Win32;

class RegKey
{
    static void Main()
    {
        // Create a subkey named Test9999 under HKEY_CURRENT_USER.
        RegistryKey test9999 =
            Registry.CurrentUser.CreateSubKey("Test9999");
        // Create two subkeys under HKEY_CURRENT_USER\Test9999. The
        // keys are disposed when execution exits the using statement.
        using(RegistryKey
            testName = test9999.CreateSubKey("TestName"),
            testSettings = test9999.CreateSubKey("TestSettings"))
        {
            // Create data for the TestSettings subkey.
            testSettings.SetValue("Language", "French");
            testSettings.SetValue("Level", "Intermediate");
            testSettings.SetValue("ID", 123);
        }

        // Print the information from the Test9999 subkey.
        Console.WriteLine("There are {0} subkeys under {1}.",
            test9999.SubKeyCount.ToString(), test9999.Name);
        foreach(string subKeyName in test9999.GetSubKeyNames())
        {
            using(RegistryKey
                tempKey = test9999.OpenSubKey(subKeyName))
            {
                Console.WriteLine("\nThere are {0} values for {1}.",
                    tempKey.ValueCount.ToString(), tempKey.Name);
                foreach(string valueName in tempKey.GetValueNames())
                {
                    Console.WriteLine("{0,-8}: {1}", valueName,
                        tempKey.GetValue(valueName).ToString());
                }
            }
        }

        using(RegistryKey
            testSettings = test9999.OpenSubKey("TestSettings", true))
        {
            // Delete the ID value.
            testSettings.DeleteValue("id");

            // Verify the deletion.
            Console.WriteLine((string)testSettings.GetValue(
                "id", "ID not found."));
        }

        // Delete or close the new subkey.
        Console.Write("\nDelete newly created registry key? (Y/N) ");
        if(Char.ToUpper(Convert.ToChar(Console.Read())) == 'Y')
        {
            Registry.CurrentUser.DeleteSubKeyTree("Test9999");
            Console.WriteLine("\nRegistry key {0} deleted.",
                test9999.Name);
        }
        else
        {
            Console.WriteLine("\nRegistry key {0} closed.",
                test9999.ToString());
            test9999.Close();
        }
    }
}
Imports System.Security.Permissions
Imports Microsoft.Win32

Public Class RegKey
    Shared Sub Main()

        ' Create a subkey named Test9999 under HKEY_CURRENT_USER.
        Dim test9999 As RegistryKey = _
            Registry.CurrentUser.CreateSubKey("Test9999")

        ' Create two subkeys under HKEY_CURRENT_USER\Test9999.
        test9999.CreateSubKey("TestName").Close()
        Dim testSettings As RegistryKey = _
            test9999.CreateSubKey("TestSettings")

        ' Create data for the TestSettings subkey.
        testSettings.SetValue("Language", "French")
        testSettings.SetValue("Level", "Intermediate")
        testSettings.SetValue("ID", 123)
        testSettings.Close()

        ' Print the information from the Test9999 subkey.
        Console.WriteLine("There are {0} subkeys under Test9999.", _
            test9999.SubKeyCount.ToString())
        For Each subKeyName As String In test9999.GetSubKeyNames()
            Dim tempKey As RegistryKey = _
                test9999.OpenSubKey(subKeyName)
            Console.WriteLine(vbCrLf & "There are {0} values for " & _
                "{1}.", tempKey.ValueCount.ToString(), tempKey.Name)
            For Each valueName As String In tempKey.GetValueNames()
                Console.WriteLine("{0,-8}: {1}", valueName, _
                    tempKey.GetValue(valueName).ToString())
            Next
        Next

        ' Delete the ID value.
        testSettings = test9999.OpenSubKey("TestSettings", True)
        testSettings.DeleteValue("id")

        ' Verify the deletion.
        Console.WriteLine(CType(testSettings.GetValue( _
            "id", "ID not found."), String))
        testSettings.Close()

        ' Delete or close the new subkey.
        Console.Write(vbCrLf & "Delete newly created " & _
            "registry key? (Y/N) ")
        If Char.ToUpper(Convert.ToChar(Console.Read())) = "Y"C Then
            Registry.CurrentUser.DeleteSubKeyTree("Test9999")
            Console.WriteLine(vbCrLf & "Registry key {0} deleted.", _
                test9999.Name)
        Else
            Console.WriteLine(vbCrLf & "Registry key {0} closed.", _
                test9999.ToString())
            test9999.Close()
        End If
   
    End Sub
End Class

Commenti

Per eseguire questa azione, l'utente deve disporre dell'autorizzazione a questo livello e al di sotto della gerarchia del Registro di sistema.

Attenzione

Non esporre RegistryKey oggetti in modo che un programma dannoso possa creare migliaia di sottochiavi senza significato o coppie chiave/valore. Ad esempio, non consentire ai chiamanti di immettere chiavi o valori arbitrari.

Vedi anche

Si applica a

CreateSubKey(String, RegistryKeyPermissionCheck)

Origine:
RegistryKey.cs

Crea una nuova sottochiave o apre una sottochiave esistente per l'accesso in scrittura, usando l'opzione di controllo delle autorizzazioni specificata.

public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey, Microsoft::Win32::RegistryKeyPermissionCheck permissionCheck);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck);
[System.Runtime.InteropServices.ComVisible(false)]
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck);
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck -> Microsoft.Win32.RegistryKey
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck -> Microsoft.Win32.RegistryKey
Public Function CreateSubKey (subkey As String, permissionCheck As RegistryKeyPermissionCheck) As RegistryKey

Parametri

subkey
String

Nome o percorso della sottochiave da creare o aprire. Questa stringa non fa distinzione tra maiuscole e minuscole.

permissionCheck
RegistryKeyPermissionCheck

Uno dei valori di enumerazione che specifica se la chiave viene aperta per l'accesso in lettura o in lettura/scrittura.

Valori restituiti

Sottochiave appena create o null se l'operazione non è riuscita. Se viene specificata una stringa di lunghezza zero per subkey, viene restituito l'oggetto corrente RegistryKey .

Attributi

Eccezioni

subkey è null.

L'utente non dispone delle autorizzazioni necessarie per creare o aprire la chiave del Registro di sistema.

permissionCheck contiene un valore non valido.

L'oggetto RegistryKey su cui viene richiamato questo metodo viene chiuso (non è possibile accedere alle chiavi chiuse).

Impossibile RegistryKey scrivere in . Ad esempio, non è stato aperto come chiave scrivibile oppure l'utente non dispone dei diritti di accesso necessari.

Il livello di annidamento supera 510.

oppure

Si è verificato un errore di sistema, ad esempio l'eliminazione della chiave o un tentativo di creare una chiave nella LocalMachine radice.

Commenti

Per eseguire questa azione, l'utente deve disporre dell'autorizzazione a questo livello e al di sotto della gerarchia del Registro di sistema.

Attenzione

Non esporre RegistryKey oggetti in modo che un programma dannoso possa creare migliaia di sottochiavi senza significato o coppie chiave/valore. Ad esempio, non consentire ai chiamanti di immettere chiavi o valori arbitrari.

Per usare il OpenSubKey metodo , è necessario disporre di un'istanza della RegistryKey classe . Per ottenere un'istanza di RegistryKey, usare uno dei membri statici della Registry classe .

Vedi anche

Si applica a

CreateSubKey(String, Boolean)

Origine:
RegistryKey.cs

Crea una nuova sottochiave o apre una sottochiave esistente con l'accesso specificato. Disponibile a partire da .NET Framework 4.6.

public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey, bool writable);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, bool writable);
[System.Runtime.InteropServices.ComVisible(false)]
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, bool writable);
member this.CreateSubKey : string * bool -> Microsoft.Win32.RegistryKey
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.CreateSubKey : string * bool -> Microsoft.Win32.RegistryKey
Public Function CreateSubKey (subkey As String, writable As Boolean) As RegistryKey

Parametri

subkey
String

Nome o percorso della sottochiave da creare o aprire. Questa stringa non fa distinzione tra maiuscole e minuscole.

writable
Boolean

true per indicare che la nuova sottochiave è scrivibile; in caso contrario, false.

Valori restituiti

Sottochiave appena create o null se l'operazione non è riuscita. Se viene specificata una stringa di lunghezza zero per subkey, viene restituito l'oggetto corrente RegistryKey .

Attributi

Eccezioni

subkey è null.

L'utente non dispone delle autorizzazioni necessarie per creare o aprire la chiave del Registro di sistema.

Impossibile scrivere l'oggetto corrente RegistryKey , ad esempio non è stato aperto come chiave scrivibile oppure l'utente non dispone dei diritti di accesso necessari.

Il livello di annidamento supera 510.

oppure

Si è verificato un errore di sistema, ad esempio l'eliminazione della chiave o un tentativo di creare una chiave nella LocalMachine radice.

Commenti

Per eseguire questa azione, l'utente deve disporre dell'autorizzazione a questo livello e al di sotto della gerarchia del Registro di sistema.

Attenzione

Non esporre RegistryKey oggetti in modo che un programma dannoso possa creare migliaia di sottochiavi senza significato o coppie chiave/valore. Ad esempio, non consentire ai chiamanti di immettere chiavi o valori arbitrari.

Per usare il CreateSubKey metodo , è necessario disporre di un'istanza della RegistryKey classe . Per ottenere un'istanza di RegistryKey, usare uno dei membri statici della Registry classe .

Si applica a

CreateSubKey(String, RegistryKeyPermissionCheck, RegistrySecurity)

Origine:
RegistryKey.cs

Crea una nuova sottochiave o apre una sottochiave esistente per l'accesso in scrittura, usando l'opzione di controllo delle autorizzazioni specificata e la sicurezza del Registro di sistema.

public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey, Microsoft::Win32::RegistryKeyPermissionCheck permissionCheck, System::Security::AccessControl::RegistrySecurity ^ registrySecurity);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, System.Security.AccessControl.RegistrySecurity? registrySecurity);
[System.Runtime.InteropServices.ComVisible(false)]
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, System.Security.AccessControl.RegistrySecurity registrySecurity);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, System.Security.AccessControl.RegistrySecurity registrySecurity);
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck * System.Security.AccessControl.RegistrySecurity -> Microsoft.Win32.RegistryKey
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck * System.Security.AccessControl.RegistrySecurity -> Microsoft.Win32.RegistryKey
Public Function CreateSubKey (subkey As String, permissionCheck As RegistryKeyPermissionCheck, registrySecurity As RegistrySecurity) As RegistryKey

Parametri

subkey
String

Nome o percorso della sottochiave da creare o aprire. Questa stringa non fa distinzione tra maiuscole e minuscole.

permissionCheck
RegistryKeyPermissionCheck

Uno dei valori di enumerazione che specifica se la chiave viene aperta per l'accesso in lettura o in lettura/scrittura.

registrySecurity
RegistrySecurity

Sicurezza del controllo di accesso per la nuova chiave.

Valori restituiti

Sottochiave appena create o null se l'operazione non è riuscita. Se viene specificata una stringa di lunghezza zero per subkey, viene restituito l'oggetto corrente RegistryKey .

Attributi

Eccezioni

subkey è null.

L'utente non dispone delle autorizzazioni necessarie per creare o aprire la chiave del Registro di sistema.

permissionCheck contiene un valore non valido.

L'oggetto RegistryKey su cui viene richiamato questo metodo viene chiuso (non è possibile accedere alle chiavi chiuse).

Impossibile scrivere l'oggetto corrente RegistryKey , ad esempio non è stato aperto come chiave scrivibile oppure l'utente non dispone dei diritti di accesso necessari.

Il livello di annidamento supera 510.

oppure

Si è verificato un errore di sistema, ad esempio l'eliminazione della chiave o un tentativo di creare una chiave nella LocalMachine radice.

Commenti

Il CreateSubKey metodo crea una chiave del Registro di sistema con il controllo di accesso specificato dal registrySecurity parametro . L'oggetto RegistryKey restituito rappresenta la chiave del Registro di sistema, ma tale oggetto non è limitato dal controllo di accesso specificato nel registrySecurity parametro .

Se permissionCheck è RegistryKeyPermissionCheck.ReadWriteSubTree, la chiave viene aperta per l'accesso in lettura/scrittura. Se permissionCheck è RegistryKeyPermissionCheck.ReadSubTree, la chiave viene aperta per l'accesso in lettura.

Per garantire la compatibilità con le versioni precedenti, la chiave viene aperta per la lettura e la scrittura se permissionCheck è RegistryKeyPermissionCheck.Default e anche la chiave padre ha RegistryKeyPermissionCheck.Default. Se la chiave padre ha un'altra impostazione, lo stato di lettura/scrittura viene controllato dall'impostazione della chiave padre.

Per eseguire questa azione, l'utente deve disporre delle autorizzazioni a questo livello e al di sotto della gerarchia del Registro di sistema.

Attenzione

Non esporre RegistryKey oggetti in modo che un programma dannoso possa creare migliaia di sottochiavi senza significato o coppie chiave/valore. Ad esempio, non consentire ai chiamanti di immettere chiavi o valori arbitrari.

Per usare il OpenSubKey metodo , è necessario disporre di un'istanza della RegistryKey classe . Per ottenere un'istanza di RegistryKey, usare uno dei membri statici della Registry classe .

Vedi anche

Si applica a

CreateSubKey(String, Boolean, RegistryOptions)

Origine:
RegistryKey.cs

Crea una nuova sottochiave o apre una sottochiave esistente con l'accesso specificato. Disponibile a partire da .NET Framework 4.6.

public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey, bool writable, Microsoft::Win32::RegistryOptions options);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, bool writable, Microsoft.Win32.RegistryOptions options);
[System.Runtime.InteropServices.ComVisible(false)]
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, bool writable, Microsoft.Win32.RegistryOptions options);
member this.CreateSubKey : string * bool * Microsoft.Win32.RegistryOptions -> Microsoft.Win32.RegistryKey
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.CreateSubKey : string * bool * Microsoft.Win32.RegistryOptions -> Microsoft.Win32.RegistryKey
Public Function CreateSubKey (subkey As String, writable As Boolean, options As RegistryOptions) As RegistryKey

Parametri

subkey
String

Nome o percorso della sottochiave da creare o aprire. Questa stringa non fa distinzione tra maiuscole e minuscole.

writable
Boolean

true per indicare che la nuova sottochiave è scrivibile; in caso contrario, false.

options
RegistryOptions

Opzione del Registro di sistema da usare.

Valori restituiti

Sottochiave appena create o null se l'operazione non è riuscita. Se viene specificata una stringa di lunghezza zero per subkey, viene restituito l'oggetto corrente RegistryKey .

Attributi

Eccezioni

subkey è null.

options non specifica un'opzione valida

L'utente non dispone delle autorizzazioni necessarie per creare o aprire la chiave del Registro di sistema.

Impossibile scrivere l'oggetto corrente RegistryKey , ad esempio non è stato aperto come chiave scrivibile oppure l'utente non dispone dei diritti di accesso necessari.

Il livello di annidamento supera 510.

oppure

Si è verificato un errore di sistema, ad esempio l'eliminazione della chiave o un tentativo di creare una chiave nella LocalMachine radice.

Commenti

Per eseguire questa azione, l'utente deve disporre dell'autorizzazione a questo livello e al di sotto della gerarchia del Registro di sistema.

Attenzione

Non esporre RegistryKey oggetti in modo che un programma dannoso possa creare migliaia di sottochiavi senza significato o coppie chiave/valore. Ad esempio, non consentire ai chiamanti di immettere chiavi o valori arbitrari.

Per usare il CreateSubKey metodo , è necessario disporre di un'istanza della RegistryKey classe . Per ottenere un'istanza di RegistryKey, usare uno dei membri statici della Registry classe .

Si applica a

CreateSubKey(String, RegistryKeyPermissionCheck, RegistryOptions)

Origine:
RegistryKey.cs

Crea una sottochiave o apre una sottochiave per l'accesso in scrittura, usando le opzioni specificate per il controllo delle autorizzazioni e il Registro di sistema.

public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey, Microsoft::Win32::RegistryKeyPermissionCheck permissionCheck, Microsoft::Win32::RegistryOptions registryOptions);
public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey, Microsoft::Win32::RegistryKeyPermissionCheck permissionCheck, Microsoft::Win32::RegistryOptions options);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, Microsoft.Win32.RegistryOptions registryOptions);
[System.Runtime.InteropServices.ComVisible(false)]
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, Microsoft.Win32.RegistryOptions options);
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck * Microsoft.Win32.RegistryOptions -> Microsoft.Win32.RegistryKey
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck * Microsoft.Win32.RegistryOptions -> Microsoft.Win32.RegistryKey
Public Function CreateSubKey (subkey As String, permissionCheck As RegistryKeyPermissionCheck, registryOptions As RegistryOptions) As RegistryKey
Public Function CreateSubKey (subkey As String, permissionCheck As RegistryKeyPermissionCheck, options As RegistryOptions) As RegistryKey

Parametri

subkey
String

Nome o percorso della sottochiave da creare o aprire.

permissionCheck
RegistryKeyPermissionCheck

Uno dei valori di enumerazione che specifica se la chiave viene aperta per l'accesso in lettura o in lettura/scrittura.

registryOptionsoptions
RegistryOptions

Opzione del Registro di sistema da usare; ad esempio, che crea una chiave volatile.

Valori restituiti

Sottochiave appena create o null se l'operazione non è riuscita.

Attributi

Eccezioni

subkey è null.

L'oggetto corrente RegistryKey è chiuso (non è possibile accedere alle chiavi chiuse).

L'oggetto corrente RegistryKey non può essere scritto in, ad esempio non è stato aperto come chiave scrivibile oppure l'utente non dispone dei diritti di accesso necessari.

Il livello di annidamento supera 510.

oppure

Si è verificato un errore di sistema, ad esempio l'eliminazione della chiave o un tentativo di creare una chiave nella LocalMachine radice.

L'utente non dispone delle autorizzazioni necessarie per creare o aprire la chiave del Registro di sistema.

Commenti

Per ottenere l'oggetto corrente RegistryKey , specificare una stringa vuota ("") per subkey.

Si applica a

CreateSubKey(String, RegistryKeyPermissionCheck, RegistryOptions, RegistrySecurity)

Origine:
RegistryKey.cs

Crea una sottochiave o apre una sottochiave per l'accesso in scrittura, usando l'opzione di controllo delle autorizzazioni, l'opzione del Registro di sistema e la sicurezza del Registro di sistema specificati.

public:
 Microsoft::Win32::RegistryKey ^ CreateSubKey(System::String ^ subkey, Microsoft::Win32::RegistryKeyPermissionCheck permissionCheck, Microsoft::Win32::RegistryOptions registryOptions, System::Security::AccessControl::RegistrySecurity ^ registrySecurity);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, Microsoft.Win32.RegistryOptions registryOptions, System.Security.AccessControl.RegistrySecurity? registrySecurity);
[System.Runtime.InteropServices.ComVisible(false)]
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, Microsoft.Win32.RegistryOptions registryOptions, System.Security.AccessControl.RegistrySecurity registrySecurity);
public Microsoft.Win32.RegistryKey CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, Microsoft.Win32.RegistryOptions registryOptions, System.Security.AccessControl.RegistrySecurity registrySecurity);
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck * Microsoft.Win32.RegistryOptions * System.Security.AccessControl.RegistrySecurity -> Microsoft.Win32.RegistryKey
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.CreateSubKey : string * Microsoft.Win32.RegistryKeyPermissionCheck * Microsoft.Win32.RegistryOptions * System.Security.AccessControl.RegistrySecurity -> Microsoft.Win32.RegistryKey
Public Function CreateSubKey (subkey As String, permissionCheck As RegistryKeyPermissionCheck, registryOptions As RegistryOptions, registrySecurity As RegistrySecurity) As RegistryKey

Parametri

subkey
String

Nome o percorso della sottochiave da creare o aprire.

permissionCheck
RegistryKeyPermissionCheck

Uno dei valori di enumerazione che specifica se la chiave viene aperta per l'accesso in lettura o in lettura/scrittura.

registryOptions
RegistryOptions

Opzione del Registro di sistema da usare.

registrySecurity
RegistrySecurity

Sicurezza del controllo di accesso per la nuova sottochiave.

Valori restituiti

Sottochiave appena create o null se l'operazione non è riuscita.

Attributi

Eccezioni

subkey è null.

L'oggetto corrente RegistryKey è chiuso. Non è possibile accedere alle chiavi chiuse.

L'oggetto corrente RegistryKey non può essere scritto in, ad esempio non è stato aperto come chiave scrivibile oppure l'utente non dispone dei diritti di accesso necessari.

Il livello di annidamento supera 510.

oppure

Si è verificato un errore di sistema, ad esempio l'eliminazione della chiave o un tentativo di creare una chiave nella LocalMachine radice.

L'utente non dispone delle autorizzazioni necessarie per creare o aprire la chiave del Registro di sistema.

Commenti

Per ottenere l'oggetto corrente RegistryKey , specificare una stringa vuota ("") per subkey.

Si applica a