ID Number: Q71202
5.00 5.10 6.00 6.00a 6.00ax 7.00
MS-DOS
Summary:
In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and 7.0, when
writing a program that accesses a floppy disk, the machine the
program runs on may have only one floppy drive. In this scenario,
the first access to drive B will generate the following message
from MS-DOS:
Insert Diskette for Drive B: and press any key when ready
This message is generated because MS-DOS allows a single physical
floppy drive to be accessed as both the A and B logical drives.
Unfortunately, the message will be written to the screen starting at
the current cursor position, which may be undesirable in many cases.
More Information:
To avoid this message, you can first determine if only a single floppy
drive is present in the system by calling INT 11h. INT 11h returns an
equipment list code in AX, where bit zero will be 1 if there are
floppy disk drives installed in the system, and bits 6 and 7 will be
the number of floppy drives. If you determine that you are working on
a single floppy system, then you can call INT 21h, Function 44h,
Subfunction 0Fh to indicate the drive you want to access next.
Once the call to this subfunction is made, MS-DOS will assume the
correct disk is in the drive and will not generate the above message.
When you want to switch drives again, call the same Subfunction 0Fh
with the new drive. The following sample code illustrates this
procedure:
Sample Code
-----------
/* Compile options needed:
*/
#include <dos.h>
#include <direct.h>
#include <stdio.h>
union REGS inregs, outregs;
#define TRUE 1
#define FALSE 0
#define DRIVE_A 0x01
#define DRIVE_B 0x02
static int SingleFloppy = TRUE; // Assume one floppy.
void main(void);
void SetDrive(char);
void main(void)
{
// Int 11h returns the equipment list code in AX.
// Bit 0 indicates whether a floppy is installed.
// Bits 6 and 7 indicate the number of drives (zero based).
int86(0x11, &inregs, &outregs);
// Do we only have one floppy drive?
if (outregs.x.ax & 0xC0)
SingleFloppy = FALSE;
// Set the initial logical status to drive A.
SetDrive(DRIVE_A);
// From this point on, MS-DOS thinks that physical drive A is the
// same as logical drive A. If you want to write to logical drive
// B, merely call SetDrive() with DRIVE_B instead.
}
void SetDrive(char DriveNum)
{
if (SingleFloppy)
{
inregs.x.ax = 0x440f;
inregs.h.bl = DriveNum;
intdos(&inregs, &outregs);
}
}