Domino Code Fragment

Code Name*
Finding the Amount of Free Space on a Drive Using LotusScript
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.144.161.116
Description*
Listed below is a LotusScript that makes the necessary API call.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Problem:
There is no built in function to find the amount of free, used, or total bytes on a drive using
LotusScript.

Solution:
A Windows API call must be employed. Listed below is a LotusScript that makes the necessary
API call.

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

Sub Main
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
End Sub