Delphi - 独立于区域设置的应用程序 [英] Delphi - Application independent of Regional Settings
问题描述
我需要独立于区域设置应用程序(D2006),最重要的是所有日期格式必须相同。
I need to make an application(D2006) independent of Regional Settings, most important all the dateformats must be the same.
对于乞讨,我想用FormatDateTime('aConstantDefined')替换所有的FormatDateTime('adateformate')。还应该将
Application.UpdateFormatSettings 和 Application.UpdateMetricSettings 设置为False。
For the begging I want to replace all the FormatDateTime('adateformate') with FormatDateTime('aConstantDefined'). Also Application.UpdateFormatSettings and Application.UpdateMetricSettings should be set to False.
有什么吗否则我应该注意?
Is there anything else I should make/take care?
LE:问题是我有两个不同区域设置的用户,他们不想统一他们的设置。我知道听起来很奇怪,但这是事实。所以,这就是为什么我需要使我的应用程序完全独立于区域设置的原因。
LE: problem is that I have users with 2 different Regional Settings, and they don't want to uniform their settings. I know that sounds strange, but this is the fact. So, this is the reason why I need to make my application totally independent of Regional Settings.
推荐答案
应用您自己的 TFormatSettings
记录。在适当的时候调用 FormatDateTime('aConstantDefined',ADateTime,myFormatSettings)
如果您的应用程序更改系统格式设置。
所以你不必使用 Application.UpdateFormatSettings
和 Application.UpdateMetricSettings
。
This will avoid mishaps if your application changes the system format settings.
So you don't have to use Application.UpdateFormatSettings
and Application.UpdateMetricSettings
.
更新:
我应该添加涉及区域设置的所有格式字符串函数,采用 TFormatSettings
重载参数。它通常用于使应用程序线程安全,但在覆盖区域设置时会派上用场。在串行化/反序列化数据进行通信/存储目的时,我经常使用这种技术。
I should add that all format string functions involved with regional settings, takes the TFormatSettings
overloaded parameter. It is often used to make the application thread-safe, but comes in handy when overriding regional settings. I often use this technique when serializing/deserializing data for communication/storing purposes.
这篇关于Delphi - 独立于区域设置的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!