ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
$INCLUDE Metacommand and Interrupt[X] Routine Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the Interrupt routine to determine the current drive
' and the amount of free space remaining on the drive.
 
' Note: The Interrupt routine requires the Quick library VBDOS.QLB. To load
' VBDOS.QLB, start Visual Basic with the /L switch.
 
' The following include file must also be present.
' $INCLUDE: 'VBDOS.BI'
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 DIM regs AS RegType                    ' Define registers
 CLS                                    ' Clear the screen
' Get current drive information; set up input and do system call
 regs.ax = &H1900
 CALL INTERRUPT(&H21, regs, regs)
 
' Convert drive information to readable form
 Drive$ = CHR$((regs.ax AND &HFF) + 65) + ":"
 
' Get disk free space; set up input values and do system call
 regs.ax = &H3600
 regs.dx = ASC(UCASE$(Drive$)) - 64
 CALL INTERRUPT(&H21, regs, regs)
 
' Decipher the results
 SectorsInCluster = regs.ax
 BytesInSector = regs.cx
 IF regs.dx >= 0 THEN
         ClustersInDrive = regs.dx
 ELSE
         ClustersInDrive = regs.dx + 65536
 END IF
 IF regs.bx >= 0 THEN
         ClustersAvailable = regs.bx
 ELSE
         ClustersAvailable = regx.bx + 65536
 END IF
 Freespace = ClustersAvailable * SectorsInCluster * BytesInSector
 
' Report results
 CLS                                    ' Clear the screen
 PRINT "Drive "; Drive$; " has a total of";
 PRINT USING "###,###,###"; Freespace;
 PRINT " bytes remaining free."