markz@microsoft.UUCP (Mark Zbikowski) (08/09/85)
I would like to trap (actually disable) control-P (^P) in a program I am writing. Normally ^P does the same thing as control-PrtSc in that it toggles "echo to printer". However, if the printer is not ready, an error message occurs. This same request can be made in several forms: o How do I stop getting ^C o How do I stop getting ^S o How do I stop getting ^P/Prt-Scrn If you can live without having these characters generate their special behaviour (^C being echoed and INT 23 generated, screen output being stopped, printer echoing getting toggled) then the following pseudo-code works fine: #define BREAKOFF 0 #define DEVICE 0x80 #define RAW 0x20 oldBreakState = GetCurrentBreakState (); SetCurrentBreakState (BREAKOFF); oldStdinBits = IOCTL (STDIN, GETBITS); if (oldStdinBits & DEVICE) IOCTL (STDIN, SETBITS, (oldStdinBits | RAW) & 0xFF); oldStdoutBits = IOCTL (STDOUT, GETBITS); if (oldStdinBits & DEVICE) IOCTL (STDOUT, SETBITS, (oldStdoutBits | RAW) & 0xFF); /* insert your code in here. Do not any system calls in the 01h-0Ch * range; no line input calls work. */ IOCTL (STDIN, SETBITS, oldStdinBits); IOCTL (STDOUT, SETBITS, oldStdoutBits); SetCurrentBreakState (oldBreakState); exit (erc); The info can be found in the IBM PC tech reference manual.