3

这个问题与这个问题有关,关于在 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 中有这样的东西吗?

4

1 回答 1

6

您需要 Windows API 调用 StrFormatByteSizeA。

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

于 2010-05-26T11:25:21.873 回答