有没有一种方法(没有明确编码)使用度量前缀显示数字?

LaB*_*cca 3 delphi string-formatting right-to-left

这个问题与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
Run Code Online (Sandbox Code Playgroud)

将返回

25.5 KB
Run Code Online (Sandbox Code Playgroud)

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

The*_*Fox 6

您需要Windows API调用StrFormatByteSizeA.

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