Find the free space on a drive

There is no built in function to find the amount of free, used, or total bytes on a drive using LotusScript. Listed below is a LotusScript that makes the necessary API call inserted into a button.
LotusScript


(Declarations)
     Declare Private Function GetDiskFreeSpace Lib "Kernel32" Alias _
     "GetDiskFreeSpaceA" (Byval lpRootPathName As String, lpSectorsPerCluster _
     As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, _
     lpTotalNumberOfClusters As Long) As Long
 
(Click)
     Dim drv As String
     Dim ret As Long
     Dim sectors As Long
     Dim bytes As Long
     Dim free As Long
     Dim total As Long
     
     drv = "C:\" 'Root directory for the drive to be checked
     ret = GetDiskFreeSpace(drv, sectors, bytes, free, total)
     
     Messagebox Cstr(sectors * bytes * free) & " bytes free on drive " & drv
     Messagebox Cstr(sectors * bytes * total) & " total bytes on drive " & drv
     Messagebox Cstr(sectors * bytes * (total - free)) & " bytes used on drive " & drv

Posted by fbrefere001 on Wednesday February 28, 2001