vbdpss.hlp (Table of Contents; Topic list)
Article Q46980
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 CALL INTERRUPT Example to Get Disk Drive Capacity, Free Space - Q46980
 
 A compiled Basic program can retrieve a disk drive's free space by
 calling MS-DOS Interrupt 21h, with subfunction 36h. This interrupt
 allows a program to obtain a drive's allocation information, which
 provides the drive size and available space. The sizes are returned in
 clusters and must be converted to bytes.
 
 This method is faster than using Basic's SHELL statement to execute
 the MS-DOS CHKDSK (check disk) command.
 
 The information in this article applies to:
 
  - The Standard and Professional Editions of Microsoft Visual Basic
    version 1.0 for MS-DOS
  - Microsoft QuickBasic versions 4.0, 4.0b, and 4.5 for MS-DOS
  - Microsoft Basic Professional Development System (PDS) versions 7.0
    and 7.1 for MS-DOS
  - Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS
 
 More Information:
 
 The code sample included below shows how to use the CALL INTERRUPT
 routine to display a drive's used space, available space, and total
 capacity. This example works under MS-DOS in Microsoft Visual Basic
 version 1.0, Microsoft QuickBasic versions 4.0, 4.0b, and 4.5,
 Microsoft Basic Compiler versions 6.0 and 6.0b, and Microsoft Basic
 PDS versions 7.0 and 7.1. For QuickBasic versions 2.0, 2.01, or 3.0
 for MS-DOS, you need to modify the program to use the CALL INT86
 statement instead of CALL INTERRUPT.
 
 Listed below is further information about MS-DOS Interrupt 21h (33
 decimal), with subfunction 36h (54 decimal). This subfunction gets
 disk-drive allocation information, from which the drive's capacity and
 remaining free space can be calculated.
 
 Invoke this function with the following register values:
 
    AH = 54
    DL = drive code (0 = default, 1 = A, 26 = Z)
 
 If the function is successful, it returns the following:
 
    AX = Sectors per cluster
    BX = Number of available clusters
    CX = Bytes per sector
    DX = Clusters per drive
 
 If the function is unsuccessful (drive invalid), it returns the
 following:
 
    AX = FFFFh
 
    See Example