有没有一种方法(无需显式编码)使用公制前缀显示数字?

发布于 2024-09-03 04:40:13 字数 568 浏览 1 评论 0原文

这个问题与 这个相关问题,关于在 Delphi 应用程序中自动使用某些 Windows 资源管理器功能。

有没有办法在Delphi中自动使用metrix前缀格式化整数?以某种方式自动获得像Windows资源管理器给出的结果?我的意思是自动将 1024 转换为 1.0 K。

比如说

FormatMetric('FileSize = %d', [26112], 1,'B')
// where the third parameter is the number of decimal digits
// and the fourth is the string that is appended

will return

25.5 KB

当然我可以编写这个代码,但是 RTL 中有类似的东西吗?

This question is relaetd to This question, on using some of the windows explorer features automatically inside a Delphi application.

Is there a way to format an integer using the metrix prefixes automatically in Delphi? Somehow to automatically obtain a result like windows explorer gives? I mean converting 1024 to 1.0 K automatically.

let's say something like

FormatMetric('FileSize = %d', [26112], 1,'B')
// where the third parameter is the number of decimal digits
// and the fourth is the string that is appended

will return

25.5 KB

Of course I can code this, but is there in the RTL something like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东风软 2024-09-10 04:40:13

您需要 Windows API 调用 StrFormatByteSizeA。

请参阅 msdn:http://msdn.microsoft。 com/en-us/library/bb759974%28VS.85%29.aspx

You need the Windows API call StrFormatByteSizeA.

See the msdn: http://msdn.microsoft.com/en-us/library/bb759974%28VS.85%29.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文