Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site microsoft.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!dual!qantel!ihnp4!houxm!mtuxo!mtunh!mtung!mtunf!ariel!vax135!cornell!uw-beaver!microsoft!markz From: markz@microsoft.UUCP (Mark Zbikowski) Newsgroups: net.micro.pc Subject: RE: intercepting ^C/^P/^S Message-ID: <8774@microsoft.UUCP> Date: Thu, 8-Aug-85 18:40:14 EDT Article-I.D.: microsof.8774 Posted: Thu Aug 8 18:40:14 1985 Date-Received: Tue, 13-Aug-85 01:21:42 EDT Organization: Microsoft Corporation Lines: 42 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.