The remarks for the function in the documentation say:
StrFormatByteSize64 can be used for either ANSI or Unicode characters. However, while StrFormatByteSize64A can be called directly, StrFormatByteSize64W is not defined. When StrFormatByteSize64 is called with a Unicode value, StrFormatByteSizeW is used.
The Delphi import is declared as:
function StrFormatByteSize64; external shlwapi32 name 'StrFormatByteSize64W';
In other words, this is a translation error in the Delphi RTL. The function StrFormatByteSize64W does not exist in shlwapi.dll.
As the documentation says, call StrFormatByteSize instead. This is handled for you by the Windows header files, but Embarcadero have not picked up this nuance when translating them.
This program demonstrates:
{$APPTYPE CONSOLE}
uses
System.SysUtils,
Winapi.ShLwApi;
procedure Main;
var
ThisSize: Int64;
szBuf: array[0..255] of Char;
cchBuf: Cardinal;
begin
ThisSize := Int64(1024)*1024*1024*256;
cchBuf := Length(szBuf);
Winapi.ShLwApi.StrFormatByteSize(ThisSize, szBuf, cchBuf);
Writeln(szBuf);
end;
begin
try
Main;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
Readln;
end.
Output:
256 GB
I have reported this to Embarcadero: https://quality.embarcadero.com/browse/RSP-29943