RegistryKey.Close 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
如果其內容已經做了修改,請關閉機碼,並將它清除至磁碟中。
public:
void Close();
public void Close ();
member this.Close : unit -> unit
Public Sub Close ()
範例
此程式代碼範例是提供給 類別之較大範例的 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
備註
在系統金鑰上呼叫這個方法不會有任何作用,因為系統密鑰永遠不會關閉。
如果您在已經關閉的 RegistryKey
實例上呼叫此方法,則不會執行任何動作。