>This code works on small drives with a parameter type of integer.
>On large drives it return -1.0697E+9 with a parameter type of integer and
>0.000E+0 with a parameter type of double.
>Does anyone know how to set this up correctly to return the correct byte count for all drive sizes.
>
>PUBLIC lpPathName, lpBytesToCall, lpTotalDiskBytes, lpFreeBytes
>lpPathName = "A:\"
>lpBytesToCall = 9
>lpTotalDiskBytes = 9
>lpFreeBytes = 9
>
>DECLARE INTEGER GetDiskFreeSpaceEx IN WIN32API AS FREESPACE STRING @lpPathName,;
>integer @lpBytesToCall, integer @lpTotalDiskBytes, integer @lpFreeBytes
>
>RetVal = FREESPACE( @lpPathName, @lpBytesToCall, @lpTotalDiskBytes, @lpFreeBytes)
>? "Path Free/Call Total/Bytes Free/Bytes"
>? lpPathName
>?? space(6)
>?? lpBytesToCall
>?? space(6)
>?? lpTotalDiskBytes
>?? space(6)
>?? lpFreeBytes
Mike,
This is because the maximum integer size in VFP is a 32 bit signed integer. GetDiskSpaceEx() requires a 64 bit integer. In order to use it, pass an 8 character string, then covert it, using something like the following:
FUNCTION StringToInteger
LPARAMETERS pcstring, plsigned
LOCAL lnresult, lnlast, lni, llsigned,;
lnmsb, lnmax
lnresult = 0
lnlast = LEN(pcstring)
IF PCOUNT() = 2
llsigned = plsigned
ELSE
llsigned = .F.
ENDIF
FOR lni = 1 TO lnlast
lnresult = lnresult + ASC(SUBSTR(pcstring, lni, 1)) * (256 ^ (lni - 1))
NEXT
IF llsigned
lnmsb = (lnlast * 8) - 1
IF BITTEST(lnresult, lnmsb)
lnmax = (2 ^ (lnmsb + 1))
lnresult = lnresult - lnmax
ENDIF
ENDIF
RETURN lnresult
ENDFUNC
George
Ubi caritas et amor, deus ibi est