如何在不特定于平台的情况下使用 TFormatSettings.Create?
我在 Delphi XE 中有以下内容:
fSettings := TFormatSettings.Create(LOCALE_USER_DEFAULT);
但我总是在编译时收到警告:
W1002 Symbol 'Create' is specific to a platform
执行此操作的正确方法是什么,这样我就不会收到警告?
I have the following in Delphi XE:
fSettings := TFormatSettings.Create(LOCALE_USER_DEFAULT);
But I always get a warning on compile:
W1002 Symbol 'Create' is specific to a platform
What is the correct way to do this, so that I do not get a warning?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您有两个选择
1) 使用重载版本,该版本使用字符串而不是
TLocaleID
2)本地禁用警告
You have two options
1) Use the overload version which uses a string instead of a
TLocaleID
2) Disable the warning locally
TFormatSettings.Create
有不同的重载。带有 LCID 的是 Windows 特有的。不带任何参数的方法和将语言环境名称作为字符串的方法更可移植。或者,如果您知道您的软件永远不会用于 Delphi for Windows 以外的任何其他用途,您可以抑制针对特定于平台的单元和过程的警告。 VCL 包含现在不受支持的平台的痕迹,例如 Linux (Kylix) 和 .NET (Delphi.NET),并且由于它们已经死了,因此将代码移植到这些平台可能会浪费时间。
There are different overloads of
TFormatSettings.Create
. The one with an LCID is specific to Windows. The one without any parameters and the one taking a locale name as a string are more portable.Or you could suppress the warning for platform-specific units and procedures, if you know your software will never be used for anything other than Delphi for Windows. The VCL contains traces of now unsupported platforms such as Linux (Kylix) and .NET (Delphi.NET), and since they're as dead as can be, making your code portable to those platforms may be a waste of time.
我的代码现在编写如下:
您可能想要调整 IFDEF 以适应未来的版本,但它给出了这个想法。
My code is now written as follows:
You will probably want to adjust that IFDEF for appropriate future versions, but it gives the idea.