home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!das.wang.com!wang!news
- From: dov@menora.weizmann.ac.il (Dov Grobgeld)
- Subject: Trapping Ctrl-Alt-Del in a Turbo Pascal program
- Organization: The Weizmann Institute of Science
- Date: Sun, 13 Dec 1992 10:20:44 GMT
- Message-ID: <9212130826.AA14016@menora.weizmann.ac.il>
- Sender: news@wang.com
- Lines: 85
-
- Here is my solution to the problem of trapping Ctrl-Alt-Del. As extra suger,
- I'm providing hooks to make this program TSR. Happy hacking!
-
- <<File: trapboot.pas>>
-
- {$m 1024,0,0} { Necesarry if you want to make the program resident. }
- {****************************************************************************}
- {* NoBoot *}
- {* *}
- {* This program stops rebooting while it is running by trapping *}
- {* Ctrl-Alt-Del. *}
- {* *}
- {* Dov Grobgeld *}
- {* 1992-12-13 *}
- {----------------------------------------------------------------------------}
-
- USES
- Dos, crt;
-
- VAR
- OldKBVec : POINTER;
-
- { Declare all variables in our interrupt routine global so that no stack }
- { allocation of variables will be done during the interrupt. }
- var
- Regs : registers;
- temp : byte;
- KBflag1: BYTE ABSOLUTE $40:$17;
-
- PROCEDURE MyKB; INTERRUPT;
- CONST
- EOI = $20;
- KB_DATA = $60;
- KB_CTL = $61;
- INT_CTL = $20;
- DEL_sc = $53; { Scancode of the del key }
-
- BEGIN
- { Check if Alt and Ctrl are pressed }
- IF ((KBFlag1 AND 4)=4) AND ((KBFlag1 and 8)=8) AND
- (Port[KB_DATA]= DEL_sc) THEN BEGIN { get scancode of pressed key }
-
- { The following four lines signals that the key is read and that the }
- { hardware interrupt is over. }
- temp:=Port[Kb_CTL];
- Port[KB_CTL]:= temp OR $80;
- Port[KB_CTL]:= temp;
- Port[INT_CTL]:= EOI;
-
- { Don't do ANYTHING here that requires BIOS. This 'writeln' is using the }
- { crt unit. }
- writeln('Ouch! That hurts!'); { Show we are here and alive! }
- END
- ELSE BEGIN
- intr($69, Regs); { Call the old interrupt routine }
- END;
- END;
-
- VAR
- Ch : CHAR;
-
- BEGIN
- GetIntVec($9, OldKBVec);
- SetIntVec($69, OldKBVec);
- SetIntVec($9, @MyKB);
-
- { Keep(0); } { Uncomment and erase the rest of the lines to make this program resident. }
-
- REPEAT
- writeln('Press escape to exit. Or Ctrl-Alt-Del if you want...');
- ch:= readkey;
- UNTIL ch=#27;
-
- { Forgetting the next line will very surely crash your computer. }
- SetIntVec($9, OldKbVec);
- END.
-
- --
- ___ ___
- / o \ o \
- Dov Grobgeld ( o o ) o |
- The Weizmann Institute of Science, Israel \ o /o o /
- "Where the tree of wisdom carries oranges" | | | |
- _| |_ _| |_
-
-