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 函数返回的目录的全球化子目录中。 方法 Unregister 从计算机中删除持久化自定义区域性文件。 删除文件后,计算机内存中自定义区域性的现有实例将继续工作,但无法创建自定义区域性的新实例。

适用于

另请参阅