gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 15:49:11 25 4
gpt4 key购买 nike

这个问题与 This question 有关,关于在 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

将返回

25.5 KB

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

最佳答案

您需要 Windows API 调用 StrFormatByteSizeA。

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

关于delphi - 有没有一种方法(无需显式编码)使用公制前缀显示数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2912020/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com