Obtaining Current Drive Information with Microsoft Basic
ID: Q62213
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
-
Microsoft QuickBASIC for MS-DOS, versions 4.0, 4.0b, 4.5
-
Microsoft BASIC Compiler for MS-DOS, versions 6.0, 6.0b
-
Microsoft BASIC Professional Development System (PDS) for MS-DOS, versions 7.0, 7.1
SUMMARY
Basic 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.).
The information in this article is also included in the Help file
provided with the Standard and Professional Editions of Microsoft
Visual Basic for MS-DOS, version 1.0.
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.
The following sample 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 for MS-DOS 1.0:
REM $INCLUDE: 'VBDOS.BI'
' Use the following include file for QuickBasic for MS-DOS:
' $INCLUDE: 'qb.bi'
' Use the following include file for Basic PDS for MS-DOS :
' $INCLUDE : 'qbx.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
Additional query words:
VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10
Keywords :
Version : MS-DOS:1.0,4.0,4.0b,4.5; :6.0,6.0b,7.0,7.1
Platform : MS-DOS
Issue type :