Path: utzoo!attcan!uunet!tektronix!tekgen!tekigm2!marks From: marks@tekigm2.MEN.TEK.COM (Mark D. Salzman) Newsgroups: comp.sys.ibm.pc Subject: Re: How to inhibit ^C from appearing Message-ID: <4499@tekigm2.MEN.TEK.COM> Date: 17 Apr 89 16:28:04 GMT References: <89Apr4.202845edt.2759@godzilla.eecg.toronto.edu> <4212@ttidca.TTI.COM> <1075@ptolemy.arc.nasa.gov> <1941@dataio.Data-IO.COM> Reply-To: marks@tekigm2.MEN.TEK.COM (Mark D. Salzman) Followup-To: comp.sys.ibm.pc Distribution: na Organization: Tektronix, Inc., Vancouver, WA. Lines: 35 One method I have used with sucess is shown below in C for MSC v4 or higher: /* * This function clears the input buffer and waits for the next character * to be typed. It ignores the BREAK (^C) signal and will not echo it to * the screen. */ #include int getkey() { union REGS rg; rg.h.ah = 0x0C; /* Use DOS call to clear keyboard buffer, */ rg.h.al = 0x07; /* and get next keyboard input. */ int86(0x21,&rg,&rg); return((int)(rg.h.al)); /* Return the key pressed */ } Drawbacks to this function are that it clears the buffer so type ahead is nullified, function keys are not handled (though I think this can be fixed), and BREAK is not actually turned off, it is just ignored by this DOS call. If any other DOS keyboard function in called (like the one that checks for a key pressed), DOS will check for BREAK and echo ^C to the screen. I used this once in a simple password program and it worked on several machines. Hope this is useful. -- Mark D. Salzman Phone: (206) 253-5542. | The more complex the mind, Tektronix Inc., P.O. Box 3500, M/S C1-936 | the greater the need for Vancouver, Washington. 98668 | the simplicity of play. E-MAIL: marks@tekigm2.MEN.TEK.COM | James T. Kirk