C# Changing sytem locale

和自甴很熟 提交于 2020-01-03 10:30:27

问题


Need to change the system locale to a different country, I have tried SystemParametersInfo(), GetKeyboardLayout() which didn't help.

How would I change the system locale in C# for a console application?


回答1:


You can use SetLocalInfo.

[DllImport("kernel32.dll")]
static extern bool SetLocaleInfo(uint Locale, uint LCType, string lpLCData);



回答2:


e.g.,

 Thread.CurrentThread.CurrentCulture = new CultureInfo("es-AR"); // Espanol - Argentina
 Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-AR");// Espanol - Argentina

e.g,

 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); // English - US
 Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");// English - US


来源:https://stackoverflow.com/questions/6926058/c-sharp-changing-sytem-locale

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!