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
上调用此方法,则此方法不执行任何操作。