How to Find the Free Disk Space from an ATEasy Application

Knowledge Base Article # Q200036

Read Prior Article Read Next Article
Summary Use GetDiskFreeSpace or GetDiskFreeSpaceEx declared in kernel32.dll or SHGetDiskFreeSpace in shell32.dll to obtain free disk space values.
Solution:

You need to call the Windows API that resides in a system dll. See the on-line help how to declare and call DLL function.

You can call GetDiskFreeSpace or GetDiskFreeSpaceEx declared in kernel32.dll or SHGetDiskFreeSpace in shell32.dll (check the Microsoft web site for declaration of these functions).

Below is a sample GetDiskFreeSpace declaration in ATEasy:

GetDiskFreeSpace(
lpRootPathName : val string,          ! root path e.g. "c:\\"
lpSectorsPerCluster: var dword,    ! sectors per cluster
pBytesPerSector: var dword,        !bytes per sector
lpNumberOfFreeClusters: var dword,  ! free clusters
lTotalNumberOfClusters: var dword:
) : Bool


Free space is calculated as:

dFreeSpace=lpSectorsPerCluster*1.0*pBytesPerSector*lpNumberOfFreeClusters


the *1.0 in the above code is used to convert to double and to avoid overflow since the result could be >4GB
Article Date 9/27/2002 10:17:39 AM
Keywords ATEasy, Free Space, GetDiskFreeSpace

0 ratings | 0 out of 5
Read Prior Article Read Next Article