>******************************************************************** >* Description.......: GetTotalSpace >* Calling Samples...: >* Parameter List....: >* Created by........: George Tasker >* Modified by.......: >******************************************************************** >function GetTotalSpace >lparameter tDirectory, tlFirstTime >local lcDir, lnResult, lcCaller, lcTotal, ; > lcFree, lcModule, lcProcname, lnResult >* Win32API declarations >lnResult=0 >if m.tlFirstTime > declare integer GetModuleHandle in Win32API; > string @lpModuleName > declare integer GetProcAddress in Win32API; > integer hModule, string @lpProcName > declare SHORT GetDiskFreeSpaceEx in Win32API; > string @lpDirectoryName,; > string @lpFreeBytesAvailableToCaller,; > string @lpTotalNumberOfBytes,; > string @lpTotalNumberOfFreeBytes >endif >store replicate(chr(0), 8) to lcCaller, lcTotal, lcFree >lcModule = "kernel32.dll" >lcProcname = "GetDiskFreeSpaceExA" >if GetProcAddress(GetModuleHandle(@lcModule), @lcProcname) # 0 > if vartype(m.tDirectory) = 'C' > lcDir = addbs(m.tDirectory) > else >* Default to the current drive > lcDir = addbs(sys(5)) > endif > if GetDiskFreeSpaceEx(@lcDir, @lcCaller, @lcTotal, @lcFree) # 0 >* Return total space >* To return free space convert lcfree > lnResult = StringToInteger(m.lcTotal) > endif >endif >return m.lnResult >endfunc >******************************************************************** >* Description.......: StringToInteger >* Calling Samples...: >* Parameter List....: >* Created by........: George Tasker >* Modified by.......: >******************************************************************** >function StringToInteger >lparameter tcString, tlSigned >local lnResult, lnLast, lnI, llSigned,; > lnMsb, lnMax >lnResult = 0 >lnLast = len(m.tcString) >* Return Signed Integer? >if PCOUNT() = 2 > llSigned = m.tlSigned >else > llSigned = .f. >endif >for lnI = 1 to m.lnLast > lnResult = m.lnResult + asc(substr(m.tcString, m.lnI, 1)) * (256 ^ (m.lnI - 1)) >next >if m.llSigned > lnMsb = (m.lnLast * 8) - 1 > if bittest(m.lnResult, m.lnMsb) > lnMax = (2 ^ (m.lnMsb + 1)) > lnResult = m.lnResult - m.lnMax > endif >endif >return m.lnResult >endfunc>