RegistryKey.DeleteSubKey Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Elimina la sottochiave specificata.
Overload
| Nome | Descrizione |
|---|---|
| DeleteSubKey(String) |
Elimina la sottochiave specificata. |
| DeleteSubKey(String, Boolean) |
Elimina la sottochiave specificata e specifica se viene generata un'eccezione se la sottochiave non viene trovata. |
DeleteSubKey(String)
Elimina la sottochiave specificata.
public:
void DeleteSubKey(System::String ^ subkey);
public void DeleteSubKey(string subkey);
member this.DeleteSubKey : string -> unit
Public Sub DeleteSubKey (subkey As String)
Parametri
- subkey
- String
Nome della sottochiave da eliminare. Questa stringa non fa distinzione tra maiuscole e minuscole.
Eccezioni
ha subkey sottochiavi figlio
Il subkey parametro non specifica una chiave del Registro di sistema valida
subkey è null
L'utente non dispone delle autorizzazioni necessarie per eliminare la chiave.
L'oggetto RegistryKey modificato è chiuso (non è possibile accedere alle chiavi chiuse).
L'utente non dispone dei diritti del Registro di sistema necessari.
Esempio
Nell'esempio seguente viene illustrato come usare DeleteSubKey.
using namespace System;
using namespace Microsoft::Win32;
public ref class RegKeyDel
{
public:
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.
RegistryKey^ testName = test9999->CreateSubKey("TestName");
RegistryKey^ testSettings = test9999->CreateSubKey("TestSettings");
// Create data for the TestSettings subkey.
testSettings->SetValue("Language", "French");
testSettings->SetValue("Level", "Intermediate");
testSettings->SetValue("ID", 123);
// delete the subkey "TestName"
test9999->DeleteSubKey("TestName");
// delete everything under and including "Test9999"
Registry::CurrentUser->DeleteSubKeyTree("Test9999");
}
};
int main()
{
RegKeyDel::Main();
}
using System;
using Microsoft.Win32;
class RegKeyDel
{
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.
RegistryKey testName = test9999.CreateSubKey("TestName");
RegistryKey testSettings = test9999.CreateSubKey("TestSettings");
// Create data for the TestSettings subkey.
testSettings.SetValue("Language", "French");
testSettings.SetValue("Level", "Intermediate");
testSettings.SetValue("ID", 123);
// delete the subkey "TestName"
test9999.DeleteSubKey("TestName");
// delete everything under and including "Test9999"
Registry.CurrentUser.DeleteSubKeyTree("Test9999");
}
}
Imports Microsoft.Win32
Public Class RegKeyDel
Public 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. The
' keys are disposed when execution exits the using statement.
Dim testName As RegistryKey = test9999.CreateSubKey("TestName")
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)
' delete the subkey "TestName"
test9999.DeleteSubKey("TestName")
' delete everything under and including "Test9999"
Registry.CurrentUser.DeleteSubKeyTree("Test9999")
End Sub
End Class
Commenti
Per eliminare le sottochiavi figlio, usare DeleteSubKeyTree.
Prestare attenzione quando si eliminano le chiavi del Registro di sistema.
Vedi anche
Si applica a
DeleteSubKey(String, Boolean)
Elimina la sottochiave specificata e specifica se viene generata un'eccezione se la sottochiave non viene trovata.
public:
void DeleteSubKey(System::String ^ subkey, bool throwOnMissingSubKey);
public void DeleteSubKey(string subkey, bool throwOnMissingSubKey);
member this.DeleteSubKey : string * bool -> unit
Public Sub DeleteSubKey (subkey As String, throwOnMissingSubKey As Boolean)
Parametri
- subkey
- String
Nome della sottochiave da eliminare. Questa stringa non fa distinzione tra maiuscole e minuscole.
- throwOnMissingSubKey
- Boolean
Indica se deve essere generata un'eccezione se non è possibile trovare la sottochiave specificata. Se questo argomento è true e la sottochiave specificata non esiste, viene generata un'eccezione. Se questo argomento è false e la sottochiave specificata non esiste, non viene eseguita alcuna azione.
Eccezioni
subkey ha sottochiavi figlio.
subkey non specifica una chiave del Registro di sistema valida e throwOnMissingSubKey è true.
subkey è null.
L'utente non dispone delle autorizzazioni necessarie per eliminare la chiave.
L'oggetto RegistryKey modificato è chiuso (non è possibile accedere alle chiavi chiuse).
L'utente non dispone dei diritti del Registro di sistema necessari.
Commenti
Per eliminare le sottochiavi figlio, usare DeleteSubKeyTree.
Prestare attenzione quando si eliminano le chiavi del Registro di sistema.