KaZaT
KaZaT

Reputation: 364

Change Customize Format in Control Panel by C#

I know my question is quite strange but maybe I can found a solution here. I usually want to change some things in Customize Format but I have to go to so many steps:

  1. Click the Start button, and then click Control Panel.
  2. Click Clock, Language, and Region, and then click Regional and Language Options.
  3. On the Formats tab, click Additional settings...
  4. Change my settings, click OK. enter image description here

Is there any way to do this just by one click? I have some knowledge to use Visual Studio to write an application. Sorry for my bad English.

Upvotes: 1

Views: 1172

Answers (1)

Reza Aghaei
Reza Aghaei

Reputation: 125207

System Level

If you want to change them at system level, you can change values of HKEY_CURRENT_USER\Control Panel\International using C# or PowerShell.

C# Example

Microsoft.Win32.Registry.SetValue(@"HKEY_CURRENT_USER\Control Panel\International", 
    "sDecimal", ",");

PowerShell Example

Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sDecimal -Value ","

Thread Level

If you want to change those values just for your current thread scope, you can set them this way:

var current = System.Threading.Thread.CurrentThread.CurrentCulture;
var culture = System.Globalization.CultureInfo.CreateSpecificCulture(current.Name); 
culture.NumberFormat.NumberDecimalSeparator = ",";
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;

Upvotes: 1

Related Questions