RegistryKey.DeleteSubKey Metoda

Definice

Odstraní zadaný podklíč.

Přetížení

DeleteSubKey(String)

Odstraní zadaný podklíč.

DeleteSubKey(String, Boolean)

Odstraní zadaný podklíč a určuje, jestli je vyvolána výjimka, pokud podklíč nebyl nalezen.

DeleteSubKey(String)

Zdroj:
RegistryKey.cs

Odstraní zadaný podklíč.

public:
 void DeleteSubKey(System::String ^ subkey);
public void DeleteSubKey (string subkey);
member this.DeleteSubKey : string -> unit
Public Sub DeleteSubKey (subkey As String)

Parametry

subkey
String

Název podklíče, který se má odstranit. Tento řetězec neodlišuje velká a malá písmena.

Výjimky

subkey podřízené podklíče.

Parametr subkey neurčoval platný klíč registru.

subkey je null

Uživatel nemá oprávnění nutná k odstranění klíče.

Manipulovaný RegistryKey objekt je zavřený (nelze získat přístup k uzavřeným klíčům).

Uživatel nemá nezbytná oprávnění pro registr.

Příklady

Následující příklad ukazuje, jak použít 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

Poznámky

Pokud chcete odstranit podřízené podklíče, použijte DeleteSubKeyTree.

Při odstraňování klíčů registru buďte opatrní.

Viz také

Platí pro

DeleteSubKey(String, Boolean)

Zdroj:
RegistryKey.cs

Odstraní zadaný podklíč a určuje, jestli je vyvolána výjimka, pokud podklíč nebyl nalezen.

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)

Parametry

subkey
String

Název podklíče, který se má odstranit. Tento řetězec neodlišuje velká a malá písmena.

throwOnMissingSubKey
Boolean

Určuje, zda má být vyvolána výjimka, pokud zadaný podklíč nebyl nalezen. Pokud je true tento argument a zadaný podklíč neexistuje, je vyvolána výjimka. Pokud je false tento argument a zadaný podklíč neexistuje, neprovede se žádná akce.

Výjimky

subkey má podřízené podklíče.

subkey Nezadá platný klíč registru a throwOnMissingSubKey je true.

subkey je null.

Uživatel nemá oprávnění nutná k odstranění klíče.

Manipulovaný RegistryKey objekt je zavřený (nelze získat přístup k uzavřeným klíčům).

Uživatel nemá nezbytná oprávnění pro registr.

Poznámky

Pokud chcete odstranit podřízené podklíče, použijte DeleteSubKeyTree.

Při odstraňování klíčů registru buďte opatrní.

Viz také

Platí pro