vbdpss.hlp (Table of Contents; Topic list)
Article Q62213
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 Visual Basic for MS-DOS: Obtaining Current Drive Information - Q62213
 
 Microsoft Visual Basic version 1.0 for MS-DOS programs can call MS-DOS
 Interrupt 21h, function 19h to get the currently selected drive.
 Before calling this interrupt, AH (the upper byte of the AX register)
 must be set to 19h. The interrupt returns the number of the current
 drive in AL (the lower byte of the AX register). The drive numbers
 correspond to the letters of the alphabet (for example, 0 = A, 1 = B,
 etc.).
 
 More Information:
 
 For more information on Interrupt 21h, function 19h, see Page 367 of
 "Advanced MS-DOS Programming, Second Edition," by Ray Duncan
 (Microsoft Press, 1988).
 
 Note that the function "CURDIR$" can also be used to get the currently
 selected drive. However, using this method requires some string
 parsing. Although the code is smaller, it may be slower.
 
 Code Example
 ------------
 
 The following example program reports the current drive.
 
    ' To try this example in VBDOS.EXE:
    ' 1. From the File menu, choose New Project.
    ' 2. Copy the code example to the Code window.
    ' 3. Press F5 to run the program.
 
    ' Use the following include file for Visual Basic 1.0 for MS-DOS:
    REM $INCLUDE: 'VBDOS.BI'
    DIM Regs AS RegType
 
    ' Set AH to 19h.
    Regs.ax = &H1900
    ' Call the Interrupt,
    CALL interrupt(&H21, Regs, Regs)
 
    ' Regs.ax must be ANDed with &HFF so that AH will be cleared.
    ' It must be cleared so the CHR$ function will be passed an
    ' ASCII code in the range of the letters A-Z (65-90).
    PRINT "The current drive is "; CHR$((Regs.ax AND &HFF) + 65)
 
    END