home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / bor_tips / ti396.asc < prev    next >
Encoding:
Text File  |  1988-05-02  |  1.3 KB  |  44 lines

  1.   TITLE  :  CAPTURING INTERRUPTS
  2.  
  3. The following program demonstrates the use of getvect and setvect
  4. to safely capture and restore interrupt vectors.  This code could
  5. be easily modified to disable the print screen utility during
  6. program execution.
  7.  
  8. #include <stdio.h>
  9. #include <dos.h>
  10.  
  11. void interrupt (*oldfunc)();
  12. int __LOOPING__ = 1;
  13.  
  14. /*--------------------------------------------------------------------
  15.  * get_out - this is our new interrupt routine
  16.  *------------------------------------------------------------------*/
  17. void interrupt get_out() {
  18.        setvect(5,oldfunc); /* restore to original interrupt routine */
  19.  
  20.      __LOOPING__ = 0;
  21.  
  22. }
  23.  
  24. /*--------------------------------------------------------------------
  25.  * capture_prtscr - installs a new interrupt for <Shift><PrtSc>
  26.  *  arguments :  func  -- new interrupt function pointer
  27.  *------------------------------------------------------------------*/
  28. void capture_prtscr(void interrupt (*func)()) {
  29.      oldfunc  = getvect(5);        /* save the old interrupt */
  30.      setvect(5,func);              /* install our interrupt handler */
  31. }
  32.  
  33. void main () {
  34.  
  35.      puts("Press <Shift><PrtSc> to terminate");
  36.      capture_prtscr(get_out);  /* capture the print screen interrupt
  37. */
  38.  
  39.      while (__LOOPING__)
  40.        ;   /* do nothing */
  41.  
  42.      puts("Success");
  43. }
  44.