Delphi - 应用程序独立于区域设置
我需要制作一个独立于区域设置的应用程序(D2006),最重要的是所有日期格式必须相同。
首先,我想用 FormatDateTime('aConstantDefined') 替换所有 FormatDateTime('adateformate') 。还 Application.UpdateFormatSettings 和 Application.UpdateMetricSettings 应设置为 False。
还有什么我应该采取/改变的吗?
LE:问题是我的用户有两种不同的区域设置,他们不想统一他们的设置。我知道这听起来很奇怪,但这是事实。因此,这就是为什么我需要使我的应用程序完全独立于区域设置的原因。
I need to make an application(D2006) independent of Regional Settings, most important all the dateformats must be the same.
For the beginning 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 take/change?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应用您自己的
TFormatSettings
记录。在适当的时候调用FormatDateTime('aConstantDefined',ADateTime,myFormatSettings)
。如果您的应用程序更改系统格式设置,这将避免发生意外。
因此,您不必使用
Application.UpdateFormatSettings
和Application.UpdateMetricSettings
。更新:
我应该补充一点,所有涉及区域设置的格式字符串函数都采用
TFormatSettings
重载参数。它通常用于使应用程序线程安全,但在覆盖区域设置时会派上用场。在出于通信/存储目的而序列化/反序列化数据时,我经常使用这种技术。Apply your own
TFormatSettings
record. CallFormatDateTime('aConstantDefined',ADateTime,myFormatSettings)
when appropriate.This will avoid mishaps if your application changes the system format settings.
So you don't have to use
Application.UpdateFormatSettings
andApplication.UpdateMetricSettings
.Update :
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.