January 1, 2005

WinTask - StrFormatByteSize

'
' StrFormatByteSize - format a number nicely
'

' Author: Joe Strazzere
'

' returns one of the following formats as appropriate:
'
'  nnn bytes
'  nnn KB
'  nnn MB
'  nnn GB
'

' "shlwapi" Alias "StrFormatByteSizeA" (ByVal _
' dw As Long, ByVal pszBuf As String, ByRef _
' cchBuf As Long) As String

 

dim ptr as unsigned

ptr=allocate(32)

pokestring(ptr,"                                ",1)

qtyin=1000000000

 

External("shlwapi", "StrFormatByteSizeA",qtyin, ptr, 32)

 

var$=peekstring$(ptr)

 

msgbox(var$)