以编程方式更改“区域和语言"操作系统设置

Changing the #39;Region and Language#39; OS setting programmatically(以编程方式更改“区域和语言操作系统设置)
本文介绍了以编程方式更改“区域和语言"操作系统设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从 C# 程序更改操作系统 (Windows 7) 的区域和语言 设置.我并不反对执行命令行命令,但我只知道如何启动 Region and Language 对话框:control/name Microsoft.RegionAndLanguage

I'd like to be able to change the Region and Language settings of the operating system (Windows 7) from a C# program. I'm not against executing command-line commands but I've only gotten as far as discovering how to launch the Region and Language dialog: control /name Microsoft.RegionAndLanguage

这是一个语言本地化问题,其中 ControlDateTimePicker 只能使用 Windows Region and Language 设置(请参阅此处的 详情);然而,更新操作系统以符合应用程序的语言设置超出了此范围,最终成为预期目标.

This is a language localisation problem where Controls like DateTimePicker can only use the Windows Region and Language settings (see here for details); however updating the operating system to conform to the application's language settings extends beyond this and is ultimately the desired goal.

我们将不胜感激建议和/或解决方法.

Suggestions and/or workarounds would be appreciated.

推荐答案

我设法实现的唯一解决方案是修改注册表.在 Windows 7 中,更改语言时,会在注册表的子项中添加一个新条目:HKEY_CURRENT_USERControl PanelDesktop.此键将包含 REG_MULTI_SZ 类型的条目 PreferredUILanguagesPending,其值将确定 UI 语言.要应用更改,当前用户需要注销并再次登录.这可以使用以下代码完成:

The only solution I managed to implement was to modify the registry. In Windows 7, when the language is changed, a new entry is added to the Registry in the subkey: HKEY_CURRENT_USERControl PanelDesktop. This key will contain the entry PreferredUILanguagesPending of type REG_MULTI_SZ and its value will determine the UI language. For the change to be applied the current user needs to log off and log in again. This can be done using the following code:

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control PanelDesktop", true);
string[] lang = {"en-ZA"};
key.SetValue("PreferredUILanguagesPending", lang, RegistryValueKind.MultiString);

语言包需要安装才能设置.如需语言包列表,请查看此处或这里.当安装超过 1 个语言包时,更改 UI 语言的选项将出现在 Control Panel >地区和语言 >键盘和语言 >显示语言.

The language pack needs to be installed before it can be set. For a list of language packs check here or here. When more than 1 language pack is installed option to change the UI language will appear in Control Panel > Region and Language > Keyboards and Languages > Display language.

这篇关于以编程方式更改“区域和语言"操作系统设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)