Skip to content

Latest commit

 

History

History
137 lines (102 loc) · 4.05 KB

nf-shlwapi-strformatbytesizew.md

File metadata and controls

137 lines (102 loc) · 4.05 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:shlwapi.StrFormatByteSizeW
StrFormatByteSizeW function (shlwapi.h)
Converts a numeric value into a string that represents the number expressed as a size value in bytes, kilobytes, megabytes, or gigabytes, depending on the size. Differs from StrFormatByteSizeA in one parameter type.
StrFormatByteSizeW
StrFormatByteSizeW function [Windows Shell]
_win32_StrFormatByteSizeW
shell.StrFormatByteSizeW
shlwapi/StrFormatByteSizeW
shell\StrFormatByteSizeW.htm
shell
00192755-9135-4193-90bc-6e312b294007
12/05/2018
StrFormatByteSizeW, StrFormatByteSizeW function [Windows Shell], _win32_StrFormatByteSizeW, shell.StrFormatByteSizeW, shlwapi/StrFormatByteSizeW
shlwapi.h
Windows
Windows 2000 Professional, Windows XP [desktop apps only]
Windows 2000 Server [desktop apps only]
StrFormatByteSizeW (Unicode)
Shlwapi.lib
Shlwapi.dll (version 4.71 or later)
Windows
19H1
StrFormatByteSizeW
shlwapi/StrFormatByteSizeW
c++
APIRef
kbSyntax
DllExport
Shlwapi.dll
API-MS-Win-shlwapi-Winrt-storage-l1-1-0.dll
api-ms-win-shlwapi-winrt-storage-l1-1-1.dll
StrFormatByteSizeW
StrFormatByteSizeW

StrFormatByteSizeW function

-description

Converts a numeric value into a string that represents the number expressed as a size value in bytes, kilobytes, megabytes, or gigabytes, depending on the size. Differs from StrFormatByteSizeA in one parameter type.

-parameters

-param qdw

Type: LONGLONG

The numeric value to be converted.

-param pszBuf [out]

Type: PWSTR

A pointer to a buffer that, when this function returns successfully, receives the converted number.

-param cchBuf

Type: UINT

The size of the buffer pointed to by pszBuf, in characters.

-returns

Type: PWSTR

Returns a pointer to the converted string, or NULL if the conversion fails.

-remarks

The first parameter of this function has different types for the ANSI and Unicode versions. If your numeric value is a DWORD, you can use StrFormatByteSize with text macros for both cases. The compiler will cast the numerical value to a LONGLONG for the Unicode case. If your numerical value is a LONGLONG, you should use StrFormatByteSizeW explicitly.

In Windows 10, size is reported in base 10 rather than base 2. For example, 1 KB is 1000 bytes rather than 1024.

The following table illustrates how this function converts a numeric value into a text string.

Numeric value Text string
532 532 bytes
1340 1.30 KB
23506 22.9 KB
2400016 2.28 MB
2400000000 2.23 GB
 

Note

The shlwapi.h header defines StrFormatByteSize as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

StrFormatByteSize64

StrFormatByteSizeA

StrFormatByteSizeEx