Delphi - Application independent of Regional Settings

一世执手 提交于 2020-01-01 07:01:41

问题


I need to make an application(D2006) independent of Regional Settings, most important all the dateformats must be the same.

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: 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.


回答1:


Apply your own TFormatSettings record. Call FormatDateTime('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 and Application.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.



来源:https://stackoverflow.com/questions/8786673/delphi-application-independent-of-regional-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!