Maybe we always see the message from the installer when our hard drive space doesn’t enough. We can get the free space of our hard drive with API function and integrate it with VB.
We can use API function: GetDiskFreeSpace on Kernel32.
Here the code:
Declare Function GetDiskFreeSpace Lib “kernel32.dll” Alias “GetDiskFreeSpaceA” (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Private Sub CheckFreeSpace()
Dim x As Long
Dim Free As Long
x = GetDiskFreeSpace (“c:/”, SecPerClus, BytePerSec, FreeClus, TotalClus)
Free = SecPerClus * BytePerClus * FreeClus
Msgbox “Free Space of Drive C:/ is: “ + Str(Free) + “ bytes”
End Sub
Simple.. huh..
Enjoy it…

0 comments:
Post a Comment