![]() |
(SST) ShlWAPI.pas Version 1.08 |
---|---|
Developer Reference |
Converts the specified, signed, 64 bit integer into a string that is a user friendly representation of its numerical value. |
Scope |
---|
Global (i.e. this function can be called/accessed from code in any unit that includes/uses (SST)ShlWAPI.pas). |
Syntax | |
---|---|
function StrFormatByteSizeW(qdw : LONGLONG; szBuf : LPWSTR; uiBufSize : UINT) : LPWSTR; |
Parameters | |
---|---|
qdw [in] | The signed, 64-bit, integer value to convert. |
szBuf [out] | A pointer to the buffer into which the zero-terminated, Unicode output string should be written. |
uiBufSize [in] | The size, including the terminating null character, in number of Unicode characters, of the buffer pointed to by szBuf. |
Return Values |
---|
If the conversion succeeded, the function returns a pointer to the formatted, Unicode string. If it fails, it returns NIL. |
Remarks |
---|
Unlike many other functions that are available both in an ANSI and a Unicode version, this function is not declared and imported in form of a default function, from which the trailing A and W have been stripped from the name. This is due to StrFormatByteSizeA and StrFormatByteSizeW not only differing with respect to the supported string types, but also in the supported file sizes (the first parameter). |
Example |
---|
PROCEDURE TForm4.TestShlWAPIStrFormatByteSizeW(Sender : TObject); VAR filehandle : HFILE; VAR sizetoconvert : LARGE_INTEGER; VAR disksize : LARGE_INTEGER; VAR totalnumfree : LARGE_INTEGER; VAR sizestrbuf : ARRAY[0 .. 127] OF WideChar; VAR bufsize : UINT; VAR apiretpointer : PWideChar; VAR newinfoline : STRING; BEGIN filehandle := 0; FillChar(sizetoconvert, SizeOf(sizetoconvert), #0); FillChar(disksize, SizeOf(disksize), #0); FillChar(totalnumfree, SizeOf(totalnumfree), #0); FillChar(sizestrbuf, SizeOf(sizestrbuf), #0); bufsize := 0; apiretpointer := NIL; newinfoline := ''; filehandle := CreateFile('C:\Windows\System32\ShlWAPI.dll', GENERIC_READ, FILE_SHARE_READ OR FILE_SHARE_WRITE, NIL, OPEN_EXISTING, 0, 0); sizetoconvert.LowPart := GetFileSize(filehandle, @sizetoconvert.HighPart); newinfoline := 'StrFormatByteSizeW called with ' + IntToStr(Int64(sizetoconvert)); Memo1.Lines.Add(newinfoline); bufsize := Length(sizestrbuf); apiretpointer := StrFormatByteSizeW(LONGLONG(sizetoconvert), sizestrbuf, bufsize); newinfoline := apiretpointer; Memo1.Lines.Add(newinfoline); CloseHandle(filehandle); GetDiskFreeSpaceEx('C:\', Int64(sizetoconvert), Int64(disksize), @totalnumfree); newinfoline := 'StrFormatByteSizeW called with ' + IntToStr(Int64(sizetoconvert)); Memo1.Lines.Add(newinfoline); bufsize := Length(sizestrbuf); apiretpointer := StrFormatByteSizeW(LONGLONG(sizetoconvert), sizestrbuf, bufsize); newinfoline := apiretpointer; Memo1.Lines.Add(newinfoline); Memo1.Lines.Add(''); END; |
The above example ought to produce an output similar to that below. |
StrFormatByteSizeW called with 351744 343 KB StrFormatByteSizeW called with 3156770816 2.93 GB |
Requirements | |
---|---|
Unit: | Declared and imported in (SST)ShlWAPI.pas |
Library: | (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj |
Unicode: | Implemented as ANSI (StrFormatByteSize and StrFormatByteSizeA) and Unicode (StrFormatByteSizeW) functions. |
Min. ShlWAPI.dll version according to MS SDK doc.: | 4.71. |
Min. ShlWAPI.dll version based on SST research: | 4.71. |
Min. OS version(s) according to Microsoft SDK doc.: | Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0. |
Min. OS version(s) according to SST research.: | Windows NT 4.0 with IE 4.0, Windows 95 with IE 4.0, Windows 98, Windows 2000 and later. |
See Also |
---|
StrFormatByteSizeA, StrFormatByteSize64A, StrFormatKBSize. |
Windows APIs: StrFormatByteSize, StrFormatByteSize64A, StrFormatByteSizeEx, StrFormatKBSize. |
Document/Contents version 1.00 Page/URI last updated on May 04, 2022 |
Copyright © Stoelzel Software Technologie (SST) 2010 - 2017 |
Suggestions and comments mail to: webmaster@stoelzelsoftwaretech.com |