共用方式為


RegistryKey.ToString 方法

定義

擷取這個機碼的字串表示。

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

傳回

表示機碼的字串。 如果指定的機碼是無效的 (找不到),則會傳回 null 值。

例外狀況

正接受存取的 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

備註

傳回值包含指定機碼的登錄路徑,以及索引鍵的十六進位值。 登錄路徑包含指定密鑰的絕對根目錄,一律從登錄的其中一個基底機碼開始,例如,HKEY_LOCAL_MACHINE。

適用於

另請參閱