home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progc
/
c_all592.arj
/
TI396.ASC
< prev
next >
Wrap
Text File
|
1992-02-25
|
2KB
|
67 lines
PRODUCT : TURBO C NUMBER : 396
VERSION : 1.0
OS : PC-DOS
DATE : November 18, 1987 PAGE : 1/1
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");
}