Microsoft KB Archive/51981

Detecting Logical Removable Drives ID Number: Q51981

3.20 3.21 3.30 3.30a 4.00 4.01 MS-DOS

Question:

If a user references a logical drive (e.g. “B:”) on a system with one physical drive and that drive is not current, MS-DOS displays the message “Insert disk in drive B and press any key when ready.” This message comes from within any of the INT 21H functions where the logical drive has to be changed. Is there any way to tell beforehand that MS-DOS will generate this message before the function is actually called?

The problem is that to hide the cursor within our product, we place it one line below the last line on the screen. If MS-DOS has to change the current logical drive, the message is displayed on this line and MS-DOS then waits for the user to press a key. Of course, since the message is not visible, the user has no idea of what is being requested.

How can I detect this situation and display my own message when this situation occurs?

Response:

There are MS-DOS services available to handle these types of situations. However, they are only available for MS-DOS Versions 3.20 and later. Interrupt 21H, function 440EH will get the logical drive status for a particular drive. Interrupt 21H, function 440FH will set the logical drive status for a particular drive.

Using these two functions, your application can check to see if a drive is acting as the drive the user has specified. If so, the application can let the action go on to MS-DOS normally. If not, your application can use service 440FH to set the logical drive status of a physical drive and thus bypass the typical MS-DOS prompting message “Insert disk in drive B and press any key when ready.”