[comp.os.msdos.programmer] How to detect media changed or drive ready on floppy?

schanin@oracle.com (Steve Chanin) (03/10/91)

In <1991Mar7.155516.9877@mck-csc.mckinsey.com>, Jeffrey Weiss asks:

   Can you tell if the drive is ready (i.e., media inserted and door closed)?
   I know there is a DOS function call where you can detect "media ready" for
   a handle, but I'd like to check before I open a file on the diskette.  Can
   you get a handle for the device itself?

why don't you use the harderr/hardretn functions in the MSC runtime
libraries to take over Interrupt 0x24 briefly.  Once you've done this,
just try to open/read a file on the drive, if there is no disk ready,
your error routines will get called, you can return a 3 to fail the
operation and no one will be the wiser (i.e. no abort, retry, fail
message will appear).

EX (in pseudo-C)
--
old_handler = _getvect(0x24)
_harderr(your_handler);
while (open("a:...",...))
   { printf("Please insert disk XXX in drive A\nPresss RETURN when ready");
     scanf(fred,"%S"); }
_setvect(old_hander)


Steve

P.S. - Say hi to Joe Tang for me and give him my email address.
--
===============================================================================
DOMAIN: sbchanin@oracle.com                                  Oracle Corporation
USMAIL: Steven Chanin, 400 Oracle Parkway, Redwood Shores, CA 94065
PHONE : (415) 506-2864