語言

RegistryKey.DeleteSubKeyTree 方法

定義

遞迴刪除子金鑰及任何子子鍵,並可選地處理例外。

多載

名稱 Description
DeleteSubKeyTree(String, Boolean)

遞迴刪除指定的子鍵及任何子子鍵,並指定若找不到子鍵是否會觸發例外。

DeleteSubKeyTree(String)

遞迴地刪除一個子鍵和任何子子鍵。

DeleteSubKeyTree(String, Boolean)

來源:
RegistryKey.cs

遞迴刪除指定的子鍵及任何子子鍵,並指定若找不到子鍵是否會觸發例外。

public:
 void DeleteSubKeyTree(System::String ^ subkey, bool throwOnMissingSubKey);
public void DeleteSubKeyTree(string subkey, bool throwOnMissingSubKey);
[System.Runtime.InteropServices.ComVisible(false)]
public void DeleteSubKeyTree(string subkey, bool throwOnMissingSubKey);
member this.DeleteSubKeyTree : string * bool -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.DeleteSubKeyTree : string * bool -> unit
Public Sub DeleteSubKeyTree (subkey As String, throwOnMissingSubKey As Boolean)

參數

subkey
String

要刪除的子鍵名稱。 此字串不區分大小寫。

throwOnMissingSubKey
Boolean

表示若找不到指定的子金鑰,是否應提出例外。 如果這個參數是 true ,且指定的子鍵不存在,則會提出例外。 若該參數為 且 false 指定的子鍵不存在,則不執行任何動作。

屬性

例外狀況

曾試圖刪除樹根蜂巢。

-或-

subkey 不指定有效的登錄子鍵,且 throwOnMissingSubKey 為 true。

subkey 是 null。

是 RegistryKey 封閉的(封閉金鑰無法存取)。

使用者沒有必要的登錄權限。

使用者沒有刪除該金鑰所需的權限。

適用於

DeleteSubKeyTree(String)

來源:
RegistryKey.cs

遞迴地刪除一個子鍵和任何子子鍵。

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

參數

subkey
String

刪除的子鍵。 此字串不區分大小寫。

例外狀況

subkey 是 null。

嘗試刪除根部蜂巢。

-或-

subkey 未指定有效的登錄檔子鍵。

發生了 I/O 錯誤。

使用者沒有刪除該金鑰所需的權限。

控的 RegistryKey 對象是封閉的(閉鎖金鑰無法被存取)。

使用者沒有必要的登錄權限。

範例

此程式碼範例是本類別更大範例 RegistryKey 的一部分。

// 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();
}
// 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();
}
' 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

備註

你必須擁有適當的權限才能刪除子鍵及其樹。

注意事項

刪除特定鍵會移除樹中該鍵以下的所有項目。 不會有任何預警。 如果你只想刪除沒有子子鍵的子金鑰,請使用該 DeleteSubKey 方法。

另請參閱

適用於