watson@spock (Steve Watson) (09/06/90)
Further to the discussion on finding drives: I would like to know how to determine whether a floppy drive has a diskette in it without provoking the "Abort/Retry/Fail" message, which kind of messes up the screen of the application. MS-Windows seems able to do this: if you click on an empty drive, you get a dialog box informing you of the situation. So does PC-Tools. I have read that the 'A/R/F' msg comes from BIOS. Is there perhaps some vector that can be hooked to intercept the floppy error and do something more graceful with it? BTW, does anyone know why A/R/F doesn't always respond to 'a' or 'f' the first time? ================================DISCLAIMER================================= Mitel pays me for my programs, not for my net postings. There4, they own the programs, including any errors found therein. The postings, including any errors, are mine alone. - Steve Watson
nol2321@dsacg4.dsac.dla.mil (Jim Dunn) (09/10/90)
The question was posed as to how to check a drive to see if it is available
without getting the annoying "Abort, Retry, Ignore" error. Below I have
a source of a program (written in microsoft or quick c) that will check the
drive H: and if it is NOT available will simply print that info to the
standard out. This can/could be easily re-written to display all available
drives, etc.
Have at it!
---Cut Here---
/********************************************************************
* WR_PROT.C
*
* Check to see if a drive is write protected
*
* Compiled with MSC 5.1 2/5/90 by Kevin English
* kje2282@venus.tamu.edu kje2282@tamvenus.bitnet
* edited a bit by jdunn@dsac.dla.mil
*
* Uses the DOS Interupts 25H and 26H to do an absolute
* read, then write of logical sector 0 of the drive.
*
* resultant ERRORLEVELs:
* 2 : error accessing drive
* 1 : write protected
* 0 : writable
*/
#include <dos.h>
char buffer[2048];
int main()
{
union REGS inregs, outregs;
struct SREGS segregs;
char far *bufferp;
inregs.h.al = 133; /* drive number 0,1 = a,b: 128,129=c,d: 133=h (lan) */
inregs.x.cx = 1; /* sectors to read */
inregs.x.dx = 0; /* starting sector number */
bufferp = buffer;
inregs.x.bx = FP_OFF(bufferp);
segregs.ds = FP_SEG(bufferp);
int86x(0x25, &inregs, &outregs, &segregs);
if (outregs.x.cflag == 1) {
printf("error reading drive H:\n");
return 2;
}
int86x(0x26, &inregs, &outregs, &segregs);
if (outregs.x.cflag == 1) {
printf("error writing drive H:\n");
return 1;
}
return 0;
}