GetDiskFreeSpaceEx
Posted: Wed Dec 31, 2003 2:30 pm
Code updated For 5.20+
We don't have extralong integers to use the API-function directly, so I made a procedure biginteger2float, which can read the result of GetDiskFreeSpaceEx
Here's the code:
We don't have extralong integers to use the API-function directly, so I made a procedure biginteger2float, which can read the result of GetDiskFreeSpaceEx
Here's the code:
Code: Select all
Declare.f biginteger2float(adr,size)
;
drive$=InputRequester("Drive info","Name of drive:","C")
If Len(drive$)=1: drive$=drive$+":": EndIf
Gosub testfree
End
testfree:
;reserve memory for 8-Byte-integers
bytesfreetocaller=AllocateMemory(8,0)
totalbytes=AllocateMemory(8,0)
totalfreebytes=AllocateMemory(8,0)
GetDiskFreeSpaceEx_(@drive$, BytesFreeToCaller, TotalBytes, TotalFreeBytes)
fbytes.f=biginteger2float(bytesfreetocaller,8)
tbytes.f=biginteger2float(totalbytes,8)
MessageRequester("Info","Free bytes on drive "+drive$+Chr(13)+Chr(13)+StrF(fbytes)+" from "+StrF(tbytes),0)
FreeMemory(bytesfreetocaller)
FreeMemory(totalbytes)
FreeMemory(totalfreebytes)
Return
Procedure.f biginteger2float(adr,size)
multi.f=1
v.f=0
For i=0 To size
b=PeekB(adr+i)
If b<0: b+256: EndIf ; signed to unsigned!
v=v+b*multi
multi=multi*256 ; may get bigger than longinteger!
; test$=test$+Str(b)+" "
Next i
; Debug test$
ProcedureReturn v
EndProcedure