ShlwApi.h定义了大量用来对数值进行格式化的操作


1. 

StrFormatKBSize function

0(共 1)对本文的评价是有帮助 评价此主题

Converts a numeric value into a string that represents the number expressed as a size value in kilobytes.

Syntax

C++
PTSTR StrFormatKBSize(
  LONGLONG qdw,
  _Out_  PTSTR pszBuf,
  UINT cchBuf
);

Parameters

qdw

Type: LONGLONG

The numeric value to be converted.

pszBuf [out]

Type: PTSTR

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

cchBuf

Type: UINT

The size of pszBuf, in characters.

Return value

Type: PTSTR

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

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 5.0 or later)

Unicode and ANSI names

StrFormatKBSizeW (Unicode) and StrFormatKBSizeA (ANSI)

See also

StrFormatByteSizeA StrFormatByteSizeW

StrFormatByteSizeW function

0(共 1)对本文的评价是有帮助 评价此主题

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 fromStrFormatByteSizeA in one parameter type.

Syntax

C++
PWSTR StrFormatByteSizeW(
  LONGLONG qdw,
  _Out_  PWSTR pszBuf,
  UINT cchBuf
);

Parameters

qdw

Type: LONGLONG

The numeric value to be converted.

pszBuf [out]

Type: PWSTR

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

cchBuf

Type: UINT

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

Return value

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 useStrFormatByteSizeW explicitly.

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

 

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 4.71 or later)

Unicode and ANSI names

StrFormatByteSizeW (Unicode)

See also

StrFormatByteSize64 StrFormatByteSizeEx StrFormatByteSizeA

StrFormatByteSize64 function

2(共 2)对本文的评价是有帮助 评价此主题

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.

Syntax

C++
PSTR StrFormatByteSize64(
  LONGLONG qdw,
  _Out_  PSTR pszBuf,
  UINT cchBuf
);

Parameters

qdw

Type: LONGLONG

The numeric value to be converted.

pszBuf [out]

Type: PSTR

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

cchBuf

Type: UINT

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

Return value

Type: PSTR

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

Remarks

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 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

 

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 5.0 or later)

Unicode and ANSI names

StrFormatByteSize64A (ANSI)

See also

StrFormatByteSizeA StrFormatByteSizeW

 

 

Send comments about this topic to Microsoft

Build date: 11/28/2012


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值