CultureAndRegionInfoBuilder.Unregister(String) 方法

定義

從本機電腦刪除自訂的文化特性。

public:
 static void Unregister(System::String ^ cultureName);
public static void Unregister (string cultureName);
static member Unregister : string -> unit
Public Shared Sub Unregister (cultureName As String)

參數

cultureName
String

要刪除之自訂文化特性的名稱。

例外狀況

cultureName 是父文化特性,或是相依文化特性的主控台後援使用者介面文化特性。

使用者沒有系統管理員權限。

cultureName 指定找不到的文化特性。

範例

下列範例示範 Unregister 方法。

// This example demonstrates the System.Globalization.Culture-
// AndRegionInfoBuilder Unregister method.
// Compile this example with a reference to sysglobl.dll.

/*
   Notes:
   This example deletes the custom culture x-en-US-sample.nlp
   file, but not the %winnt%\Globalization directory that contains the file.
*/

using System;
using System.Globalization;

class Sample
{
    public static void Main()
    {
    try
        {
        Console.Clear();
        Console.WriteLine("Unregister the \"x-en-US-sample\" " +
                          "custom culture if it already exists...");
        CultureAndRegionInfoBuilder.Unregister("x-en-US-sample");
        Console.WriteLine("The custom culture was unregistered successfully.");
        }
    catch (Exception e)
        {
        Console.WriteLine("Error while unregistering...");
        Console.WriteLine(e);
        }
    }
}
/*
This code example produces the following results:

Unregister the "x-en-US-sample" custom culture if it already exists...
The custom culture was unregistered successfully.

*/
' This example demonstrates the System.Globalization.Culture-
' AndRegionInfoBuilder Unregister method.
' Compile this example with a reference to sysglobl.dll.
'
'   Notes:
'   This example deletes the custom culture x-en-US-sample.nlp 
'   file, but not the %winnt%\Globalization directory that contains the file.
'

Imports System.Globalization

Class Sample
    Public Shared Sub Main() 
        Try
            Console.Clear()
            Console.WriteLine("Unregister the ""x-en-US-sample"" " & _
                               "custom culture if it already exists...")
            CultureAndRegionInfoBuilder.Unregister("x-en-US-sample")
            Console.WriteLine("The custom culture was unregistered successfully.")
        Catch e As Exception
            Console.WriteLine("Error while unregistering...")
            Console.WriteLine(e)
        End Try
    
    End Sub
End Class
'
'This code example produces the following results:
'
'Unregister the "x-en-US-sample" custom culture if it already exists...
'The custom culture was unregistered successfully.
'

備註

方法 Unregister 會執行 方法的 Register 反轉。 方法 Register 會將自定義文化特性儲存為本機計算機上的檔案,位於 Windows API GetWindowsDirectory 函式所傳回之目錄的 Globalization 子目錄中。 方法 Unregister 會從計算機刪除保存的自定義文化特性檔案。 刪除檔案之後,計算機記憶體中自定義文化特性的現有實例會繼續運作,但無法建立自定義文化特性的新實例。

適用於

另請參閱