Disabling the keyboard
Mark William Hopkins
markh at csd4.csd.uwm.edu
Sun Mar 17 04:46:46 AEST 1991
In article <1991Mar11.193729.3291 at ssd.kodak.com> wieser at bissun.kodak.com (Jim Wieser) writes:
>How do you temporarily disable the keyboard on a PC under
>DOS using MSC short of installing a new interrupt handler?
Installing a new interrupt handler is the easiest way by far. This should
work on IBM-compatibles (possibly except for the PcJr):
------------------------------------------------------------
KbdInt.h:
extern void DisableKbd(void);
extern void EnableKbd(void);
------------------------------------------------------------
KbdInt.c:
#include <dos.h>
#pragma check_stack(off)
#pragma check_pointer(off)
static unsigned /* Keyboard buffer */
far *HeadP = (unsigned far *)0x0040001a,
far *TailP = (unsigned far *)0x0040001c;
static void (interrupt far *OldKbd)(void);
static void interrupt far Ignore(void) {
/* Get the key but ignore it. */
(*OldKbd)();
if (*HeadP == *TailP) return;
*HeadP += 2;
if (*HeadP > 0x003d) *HeadP = 0x001e;
}
void DisableKbd(void) {
OldKbd = _dos_getvect(0x09);
_dos_setvect(0x09, Ignore);
}
void EnableKbd(void) { _dos_setvect(0x09, OldKbd); }
------------------------------------------------------------
The only question I have is: how do you plan to re-enable the keyboard?
More information about the Comp.lang.c
mailing list