Microsoft KB Archive/71202

{|
 * width="100%"|

Accessing Drive w/o MS-DOS Message on Single Floppy System

 * }

Q71202

5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg kbcode -- The information in this article applies to: - The C Run-time (CRT), included with: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SUMMARY ======= 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 Interrupt 11h. Interrupt 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 Interrupt 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 #include #include 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); } } Additional reference words: kbinf 6.00 6.00a 6.00ax 7.00 1.00 1.50 KBCategory: kbprg kbcode KBSubcategory: CRTIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT