Microsoft KB Archive/50228

= How to Use CALL INTERRUPTX to Get Name of Current Directory =

Article ID: 50228

Article Last Modified on 11/21/2006

-

APPLIES TO


 * 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

-



This article was previously published under Q50228



SUMMARY
This article gives an explanation and code example for how CALL INTERRUPTX can be used to get the name of the current directory on a specified drive using Microsoft QuickBasic.



MORE INFORMATION
MS-DOS interrupt 21 hex function 47 hex returns an ASCIIZ string that describes the name of the current directory and the path from the root to the current directory. An ASCIIZ string is a series of ASCII characters terminated by a null byte. A null byte or null character is a 1-byte data item (a char in C) that has the value zero. It is the first character on any ASCII chart.

The &quot;current directory&quot; is the subdirectory that you are currently working in. The MS-DOS CHDIR (CD) command is used to change the current directory.

Note: It is necessary to use the CALL INTERRUPTX statement to call this DOS function. This is not possible with the CALL INTERRUPT statement. CALL INTERRUPT does not allow a program to change the value of the DS or ES registers. CALL INTERRUPTX allows both DS and ES to be set.

Code Example
REM $INCLUDE: 'qb.bi' ' For Basic PDS 7.00 and QBX.EXE the include file is 'QBX.BI'

DIM InRegs AS RegTypeX DIM OutRegs AS RegTypeX DIM CurrentDirectory AS STRING * 64

CurrentDirectory = STRING$(64, CHR$(32))  '32 is ASCII for SPACE InRegs.Ax = &H4700                      'Function Number     in AH InRegs.Si = VARPTR(CurrentDirectory)     'Offset of Variable  in SI InRegs.Ds = VARSEG(CurrentDirectory)     'Segment of Variable in DS InRegs.Dx=0                              'Drive Number        in DX                                         '(0=default, 1=A, etc.) CALL INTERRUPTX(&H21, InRegs, OutRegs) CLS PRINT &quot;Current Directory = &quot; + RTRIM$(CurrentDirectory) END

Additional query words: QuickBas BasicCom

Keywords: KB50228

-

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

© Microsoft Corporation. All rights reserved.