开发者

C# Changing sytem locale

开发者 https://www.devze.com 2023-03-25 18:48 出处:网络
Need to change the system locale to a different country, I have tried SystemParametersInfo(), GetKeyboardLayout() which didn\'t help.

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 applicati开发者_运维百科on?


You can use SetLocalInfo.

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消