如何更改Windows用户的区域设置/日期格式? [英] How can I change a Windows user's regional settings/date format?

查看:1393
本文介绍了如何更改Windows用户的区域设置/日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用VB6 / COM +应用程序,它输出的基础上在控制面板,区域设置的短日期设置,日期/时间值,为运行它的用户。该程序,然后分析该输出有预计的日期格式可配置的设置,并在UI呈现。

I use a VB6/COM+ application which outputs date/time values based on the short date settings in the Control Panel, Regional Settings, for the user that runs it. The program that then parses that output has a configurable setting for the date format it expects, and presents in the UI.

例如。如果用户的区域设置为MM / DD / YYYY,它输出2008.02.04,期待18/06/2009申请失败字符串未被识别为有效的DateTime。

e.g. If the regional setting for the user is set to mm/dd/yyyy, and it outputs 06/18/2009, the application expecting "18/06/2009" fails with "String was not recognized as a valid DateTime".

由于我们平时运行该应用程序作为服务帐户,这是我们不作为交互式登录创建一个配置文件,我们一般设置正确的日期格式,然后勾选应用所有设置为当前用户帐户和默认用户配置文件选项。

As we usually run this application as a service account, which we have not logged in as interactively to create a profile, we generally set the correct date format and then tick the "Apply all settings to the current user account and the default user profile" option.

我想是让我为这个烂摊子编写的C#配置实用程序能够以编程设定的日期格式,交给用户。

I would like to be make the C# configuration utility I have written for this mess to be able to set the date format programmatically for a given user.

修改
我想无非就是改代码,但没有在这个时候这样做的能力。

Edit I would like nothing more than to change the code, but do not have the ability to do so at this time.

我也知道,我所问的是一个坏事情。至于它应该是用户的选择 - 我上午用户,我明确地创建它的任务;我只是想通过一个脚本方法来设置日期格式,而不是做一下自己。

I also know that what I am asking is a bad thing to do. With regards to "it should be the user's choice" - I am that user, as I create it explicitly for the task; I just want to set the date format by a scripted method, rather than having to do the clicking myself.

推荐答案

这是专微软气馁。你可能会想出任何解决方案将是一个肮脏的黑客,这将可能很快停止工作。

This is specifically discouraged by Microsoft. Any solution you may come up with will be a filthy hack that will probably stop working soon.

想想这样说:你是谁,以决定这些设置?难道你不认为这是用户的决定。

Think of it this way: who are you to decide those settings? Don't you think that's the user's decision?

回到主题:?找到该应用程序进行通信的,如YYYYMMDD一个明确的格式。 ,显示可以然后只需尊重实际用户的设置,因为它应该应用

Back on topic: find an unambiguous format for the applications to communicate in, such as YYYYMMDD. The application that displays can then simply respect the actual user settings, as it should.

不过,既然你不能改变它,就捅到注册表:

But, since you can't change it, just poke into the registry:

当前用户:

HKEY_CURRENT_USER\Control Panel\International

具体的用户:

HKEY_USERS\(user SID)\Control Panel\International

默认用户:

HKEY_USERS\.DEFAULT\Control Panel\International

sShortDate可能是你想要改变的人。

sShortDate is probably the one you want to change.

这篇关于如何更改Windows用户的区域设置/日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆