Microsoft KB Archive/11785

= Getting the DTA Address Using INT86 =

Article ID: 11785

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

-



This article was previously published under Q11785



SUMMARY
Problem:

I would like to search for files with a given extension, save them in an array, and display them on the screen for user selection using Visual Basic for MS-DOS version 1.0 and the MS-DOS interrupt routine. I have written a sample program that calls function 4E and 4F to find the desired files. They appear to be working correctly, as the flag returned in the low byte of register AX is showing 0 for each successful find and 18 when no files exist or when the last file has been found. However, I do not know how to read the DTA (Disk Transfer Address) after I successfully find a file, thus I cannot store the filename for later display.

Response:

In QuickBasic for MS-DOS versions 2.0, 2.01, and 3.0, you can perform MS-DOS Interrupts by calling the external routine INT86. In the Standard and Professional Editions of Visual Basic for MS-DOS version 1.0; and QuickBasic for MS-DOS versions 4.0, 4.00b, and 4.5, you can call the external routines INT86OLD, INT86XOLD, INTERRUPT, and INTERRUPTX.

It is difficult to find the current DTA of a program (and its offset is subject to change without notice); therefore, it is better to ask MS-DOS (via INT 21, function Hex 1A "Set DTA") to reassign the DTA to a location over which you have control. For the application indicated, you should try the following:


 * 1) Issue the MS-DOS function call to change the DTA address (Interrupt 21h, function Hex 1A) to an address of a structure in your code space (this way you will know where to find it).
 * 2) Perform your "Find first" (Interrupt 21h, function Hex 4E).
 * 3) Perform your loop of "Continue file search" (Interrupt 21h, function Hex 4F).

Within your loop you may check your variables in the structure as desired. The "Microsoft MS-DOS Programmer's Reference" manual includes an example of how to set up the structure for the DTA in assembler.

The book "Advanced MS-DOS," by Ray Duncan (Microsoft Press, 1986) also is a very helpful reference for using MS-DOS function calls.

Additional query words: VBmsdos QuickBas BasicCom

Keywords: KB11785

-

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

© Microsoft Corporation. All rights reserved.