[comp.lang.c] Help with Dos write protect error

ashworth@handel.cs.colostate.edu (brian lee ashworth) (03/21/91)

I am using MSC 5.1 and am trying to find a high level dos or possibly bios
call to determine the status of the disk drive.  In particular I am trying
to detect what the status of the write protect tab is.  My problem stems
from the fact that I get a write protect error Abort, Retry, Ignore? message
when I try to write to a file using fopen and fprintf.  I would like to 
detect the status before I write to the file so that dos doesn't have a 
chance to display it's error.  I have looked in many books and dos manuals
for bios calls with no luck.

thanks in advance!

-------------------------------------------------------------------------------
| Brian Ashworth CS major trying to just make it through                      |
| E-mail address ashworth@handel.colostate.edu                                |
-------------------------------------------------------------------------------

Mark.Tutt@f88.n363.z1.fidonet.org (Mark Tutt) (03/23/91)

 bla> I am using MSC 5.1 and am trying to find a high level dos or possibly 
 bla> bios
 bla> call to determine the status of the disk drive.  In particular I am 
 bla> trying
 bla> to detect what the status of the write protect tab is.  My problem stems
 bla> from the fact that I get a write protect error Abort, Retry, Ignore? 
 bla> message
 bla> when I try to write to a file using fopen and fprintf.  I would like to 
 bla> detect the status before I write to the file so that dos doesn't have a 
 bla> chance to display it's error.  I have looked in many books and dos 
 bla> manuals
 bla> for bios calls with no luck.

What you are looking for is INT 13H Function 01H. It will return 03H in the AL 
register if the disk is write protected. However, what it returns is the info 
from the most recent disk operation, so you would have to call another disk 
function before calling this one. Perhaps INT 13 Function 00H, reset disk 
system would be the safest.

Hope this helps!

Mark



--  
Mark Tutt - via FidoNet node 1:363/42
UUCP: 
ARPA: Mark.Tutt@f88.n363.z1.fidonet.org


\

martin@iastate.edu (Calsyn Martin Robert) (03/26/91)

In article <351.27EC635A@business.UUCP> Mark.Tutt@f88.n363.z1.fidonet.org (Mark Tutt) writes:

> bla> ...  My problem stems
> bla> from the fact that I get a write protect error Abort, Retry, Ignore? 
> bla> message

You could eliminate this message for other nasty DOS errors like drive
not ready, data error, media failure, etc by intercepting the DOS
critical error handler - I believe its DOS INT 24H.  This interupt is
available in more recent (3.30+) versions of MS-DOS.

---
Martin R. Calsyn                                   martin@iastate.edu
Project Vincent Systems Support                    gg.mrc@isumvs.bitnet
Iowa State University Computation Center           voice: (515) 294-9889 
Ames, Iowa 50011                                   fax:   (515) 294-1717