home *** CD-ROM | disk | FTP | other *** search
- TITLE : CAPTURING INTERRUPTS
-
- The following program demonstrates the use of getvect and setvect
- to safely capture and restore interrupt vectors. This code could
- be easily modified to disable the print screen utility during
- program execution.
-
- #include <stdio.h>
- #include <dos.h>
-
- void interrupt (*oldfunc)();
- int __LOOPING__ = 1;
-
- /*--------------------------------------------------------------------
- * get_out - this is our new interrupt routine
- *------------------------------------------------------------------*/
- void interrupt get_out() {
- setvect(5,oldfunc); /* restore to original interrupt routine */
-
- __LOOPING__ = 0;
-
- }
-
- /*--------------------------------------------------------------------
- * capture_prtscr - installs a new interrupt for <Shift><PrtSc>
- * arguments : func -- new interrupt function pointer
- *------------------------------------------------------------------*/
- void capture_prtscr(void interrupt (*func)()) {
- oldfunc = getvect(5); /* save the old interrupt */
- setvect(5,func); /* install our interrupt handler */
- }
-
- void main () {
-
- puts("Press <Shift><PrtSc> to terminate");
- capture_prtscr(get_out); /* capture the print screen interrupt
- */
-
- while (__LOOPING__)
- ; /* do nothing */
-
- puts("Success");
- }
-