home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / MASTER-1.ZIP / SOURCE / CHAP06 / CHAP06.LZH / CTRLBRK.CPP < prev    next >
C/C++ Source or Header  |  1992-07-17  |  539b  |  23 lines

  1. // ctrlbrk.cpp
  2. // Shows how to intercept a Ctrl-Break to avoid
  3. // terminating a program.  Will not work if launched
  4. // from the IDE!  Execute from command line to
  5. // see it in operation.
  6. #include <stdio.h>
  7. #include <conio.h>
  8. #include <dos.h>
  9.  
  10. int IgnoreCtrlBrk(void)
  11. // Return 0 to abort program; non-0 to continue
  12. { return 1; }
  13.  
  14. void main(void)
  15. {
  16.   ctrlbrk( IgnoreCtrlBrk );
  17.   while (1) {
  18.     printf("Press <space> to halt; Ctrl-Break is intercepted...");
  19.     if (kbhit())
  20.       { if (getch()==' ') return; }
  21.   };
  22. }
  23.