Microsoft KB Archive/25635

Get Logical Floppy Disk Status PSS ID Number: Q25635 Article last modified on 03-24-1993 PSS database name: O_MSDOS

3.x 4.00 5.00 6.00

MS-DOS

Question:

Given a MS-DOS floppy-disk drive letter, we would like to determine the following:


 * 1) If the drive is a floppy drive with no floppy inserted
 * 2) If the drive is a logical drive (i.e., Drive B when Drive A is active, or Drive A when Drive B is active)

We would like to determine these factors without receiving the “Drive not read” critical error. Can this be done?

Response:

This concerns determining if a floppy disk is in the drive, and how to determine which logical drive a physical drive is acting as.

You can use the following two methods to determine if a disk is in the drive without raising the INT 24H critical error handler:


 * 1) Use ROM BIOS INT 13H, function 2H. For this function, use head 0, track 0, sector 1, and read one sector (the data of this read is not important, but the drive access time is; these numbers would result in a fast access).
 * 2) Use MS-DOS INT 25H, Absolute Disk Read. The same logic that applied to INT 13H applies here.

With either of these methods, you will not generate any errors that have to be trapped through INT 24H if there is no disk in the drive. Instead, you will receive an error code stating that there is no disk in the drive.

As for determining which logical drive a physical drive is acting as, you first must determine if this is a valid question. If the system has two floppy drives, it would not be valid to test if physical Drive A is acting as logical Drive A or B. Use ROM BIOS INT 11H, Get Equipment Status, to determine if there are one or two physical drives in the system. Continue with this logic only if there is one drive.

If there is only one physical floppy drive on the system and you are using MS-DOS Version 3.20 or above, there is an IOCTL call to determine which logical drive a physical drive is acting as. It is INT 21H, AH = 44H, AL = 0EH, and BL = 0 (this is Drive A). This call returns (AL == 1) if Drive A is the active drive, or (AL == 2) if Drive B is the active drive.

In addition, your application can set the logical drive with a similar function (INT 21H, IOCTL 440FH, Set Logical Drive). INT 21H, function 44H, Get/Set Logical Drive, is new to MS-DOS Version 3.20.

Additional reference words: 3.20 4.00 5.00 6.00

Copyright Microsoft Corporation 1993.