求两个API函数的用法: StrFormatByteSize 和 StrFormatByteSize64

「已注销」 2008-12-22 04:34:08
Private Declare Function StrFormatByteSize Lib "shlwapi" _
Alias "StrFormatByteSizeA" _
(ByVal dw As Long, _
ByVal pszBuf As String, _
ByVal cchBuf As Long) As Long

Private Declare Function StrFormatByteSize64 Lib "shlwapi.dll" _
Alias "StrFormatByteSize64A" _
(ByVal qdw As Double, _
ByVal szBuf As String, _
ByVal uiBufSize As Long) As Long

StrFormatByteSize 的用法是这样的:

Private Function FormatByteSize(dwBytes As Long) As String
Dim sBuff As String
Dim dwBuff As Long

sBuff = Space$(32)
dwBuff = Len(sBuff)

If StrFormatByteSize(dwBytes, sBuff, dwBuff) <> 0 Then
FormatByteSize = Left$(sBuff, InStr(sBuff, Chr$(0)) - 1)
End If
End Function

Private Sub Command1_Click()
Print FormatByteSize(2147483647)
Print FormatByteSize(37423218.34)
Print FormatByteSize(3742321.34)
Print FormatByteSize(374232.34)
Print FormatByteSize(37423.34)
Print FormatByteSize(3742.34)
Print FormatByteSize(1024)
Print FormatByteSize(1023)
Print FormatByteSize(374.34)
Print FormatByteSize(37.34)
End Sub

StrFormatByteSize64怎么用?
...全文
627 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2008-12-22
  • 打赏
  • 举报
回复
http://coding.derkeiler.com/Archive/Delphi/alt.comp.lang.borland-delphi/2005-06/msg00141.html

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧