Microsoft KB Archive/62213

= Obtaining Current Drive Information with Microsoft Basic =

Article ID: 62213

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft Visual Basic for MS-DOS
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q62213



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 &quot;Advanced MS-DOS Programming, Second Edition,&quot; by Ray Duncan (Microsoft Press, 1988).

Note that the function &quot;CURDIR$&quot; 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 &quot;The current drive is &quot;; 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: KB62213

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.