问题
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