Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>hardresume() hardware error handler function</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 hardresume()            Hardware Error Handler Function

 #include   <dos.h>

 void       hardresume(rescode);
 int        rescode;                     Result code

    hardresume() can be called to return to MS-DOS after an interrupt
    0x24 has occurred.  'rescode' contains an abort (2), retry (1) or
    ignore (0) result code.    Abort the program by invoking DOS
    interrupt 0x23, the control-break interrupt.

       Returns:     There is no return value.

   Portability:     MS-DOS only.

   -------------------------------- Example ---------------------------------

    The following statements replace the DOS "A)bort, R)etry, F)ail?"
    prompt with one that first checks to see if the error was caused by
    trying to write to a write-protected disk.

           #include <stdio.h>
           #include <dos.h>

           int handler(int errval, int ax, int bp, int si)
           {
               char drive;

               if (ax < 0) {               /* device error */
                   bdosptr(0x9, "DOS device error$", 0);
                   hardretn(-1);           /* return to program */
               }
               drive = 'A' + (ax & 0xFF);
               if (errval == 0) {          /* write protect error */
                   bdosptr(0x9, "Put a disk which is NOT
                            write protected in drive $", 0);
                   bdos(0x2, drive, 0);    /* write drive name */
                   bdosptr(0x9, ": <RETURN>$", 0);
                   bdos(0x8, 0, 0);        /* wait for a key to be pressed */
                   bdosptr(0x9, "\r\n$", 0);
                   hardresume(1);          /* tell DOS to RETRY */
               }
                    /* some other disk error */
               bdosptr(0x9, "Disk error on drive $", 0);
               bdos(0x2, drive, 0);
               return(2);                 /* ABORT program */
           }

           main()
           {
               FILE *f;

               harderr(handler);         /* attach error handler */

               printf("Hit a key to try to create file on drive A:\n");
               getch();
               if ((f = fopen("A:\NEWFILE.NEW", "w+")) == NULL)
                   printf("Can't open file!\n");
               printf("DONE\n");
           }


See Also: harderr() hardretn() setjmp()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson