Dim di As New DriveInfo("C") Dim tf As Long = di.TotalFreeSpace
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long Private Sub Form_Load() Dim Sectors As Long Dim Bytes As Long Dim FreeC As Long Dim TotalC As Long Dim Freeb As Variant GetDiskFreeSpace "C:\", Sectors, Bytes, FreeC, TotalC Freeb = CDec(FreeC) * CDec(Sectors) * CDec(Bytes) End Sub
'$INCLUDE: 'qb.bi' DIM regs AS RegType regs.ax = &H3600 regs.dx = &H0 CALL interrupt(&H21, regs, regs) CLS PRINT "Sectors per cluster : "; regs.ax PRINT "Number of free clusters: "; regs.bx PRINT "Bytes per sector : "; regs.cx PRINT "Total clusters on drive: "; regs.dx PRINT "Free space : "; CLNG(regs.ax) * CLNG(regs.bx) * CLNG(regs.cx) PRINT "Total space : "; CLNG(regs.ax) * CLNG(regs.cx) * CLNG(regs.dx) END
INT 21 - DOS 2+ - GET FREE DISK SPACE AH = 36h DL = drive number (00h = default, 01h = A:, etc) Return: AX = FFFFh if invalid drive else AX = sectors per cluster BX = number of free clusters CX = bytes per sector DX = total clusters on drive Notes: free space on drive in bytes is AX * BX * CX total space on drive in bytes is AX * CX * DX "lost clusters" are considered to be in use according to Dave Williams' MS-DOS reference, the value in DX is incorrect for non-default drives after ASSIGN is run this function does not return proper results on CD-ROMs; use AX=4402h"CD-ROM" instead (FAT32 drive) the reported total and free space are limited to 2G-32K should they exceed that value