C# 到达控制面板';使用c在pc上的s功能#
我尝试进入开始->控制面板->区域和语言选项->自定义->十进制符号 并从用c#编写的windows窗体应用程序中更改该值。我搜索与此不同的解决方案:C# 到达控制面板';使用c在pc上的s功能#,c#,C#,我尝试进入开始->控制面板->区域和语言选项->自定义->十进制符号 并从用c#编写的windows窗体应用程序中更改该值。我搜索与此不同的解决方案: System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture; string decimalSeparator = ci.NumberFormat.CurrencyDecimalSeparator; 因为这些系统、全球
System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture;
string decimalSeparator = ci.NumberFormat.CurrencyDecimalSeparator;
因为这些系统、全球化或文化的东西看不到用户是否只是在他/她的计算机上手动更改该值
如何处理此问题,请提供帮助。以下是一个如何更改十进制字符然后恢复原始字符的示例
using System;
using System.Security.Permissions;
using Microsoft.Win32;
[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, ViewAndModify="HKEY_CURRENT_USER")]
namespace sampleProgram
{
public class sampleClass
{
static void Main()
{
// open the registry key holding control panel international settings
using (RegistryKey international = Registry.CurrentUser.OpenSubKey("Control Panel\\International", true))
{
// get and display the current decimal character
string original_sDecimal = international.GetValue("sDecimal").ToString();
Console.WriteLine("original sDecimal='" + original_sDecimal + "'");
Console.WriteLine("Press enter:");
Console.ReadLine();
// temporarily change the decimal character
string alternate_sDecimal = "@";
international.SetValue("sDecimal", alternate_sDecimal);
Console.WriteLine("alternate sDecimal='" + international.GetValue("sDecimal").ToString() + "'");
Console.WriteLine("Press enter:");
Console.ReadLine();
// put back the original decimal character
international.SetValue("sDecimal", original_sDecimal);
Console.WriteLine("restored original sDecimal='" + international.GetValue("sDecimal").ToString() + "'");
Console.WriteLine("Press enter:");
Console.ReadLine();
}
}
}
}
有关此主题的更多信息,请查看此处:设置位于注册表中。这将有助于:如何从代码中访问?有图书馆吗?