求两个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怎么用?