BBS: Inland Empire Archive Date: 04-01-92 (10:51) Number: 186 From: MARK BUTLER Refer#: 143 To: JEAN CREPEAU Recvd: NO Subj: Special Event Trapping Conf: (2) Quik_Bas
In a message to ALL, CHAD FAWCETT wrote:
CF> Hey, is there any good way to trap special events like CTRL-ALT-DEL
CF> or CTRL-Break?
Trapping a reboot attempt (ctrl-alt-del) is not hard, but I haven't
had much luck foiling ctrl-brk. I used to have a ctrl-brk trap that
worked but only with older XT keyboards. However, the following
snippet will still foil a warmboot attempt...
---------------------------8< CUT HERE 8<----------------------------
'***** set up control-alt-delete trap *****
KEY 16, CHR$(12) + CHR$(83)
ON KEY(16) GOSUB RebootHandler
KEY(16) ON
'**** a program simulation ******
Counter% = 0
SimProgram:
CLS
x% = CSRLIN
y% = POS(0)
DO
LOCATE x%, y%
PRINT "This is a program that is executing something";
PRINT "Try to reboot out of it or press [ESC] to end"
Counter% = Counter% + 1
PRINT
PRINT "Execution #"; Counter%
LOOP UNTIL INKEY$ = CHR$(27)
PRINT
PRINT "That's all folks!"
END
'**** this will handle any reboot attempts *****
RebootHandler:
CLS
PRINT "No-way, no rebooting out of *this* program!"
PRINT "Hit any key to continue..."
DO: LOOP UNTIL LEN(INKEY$)
RETURN SimProgram
---------------------------8< CUT HERE 8<----------------------------
If anyone has a reliable CTRL-BRK trap that will work with *any*
keyboard I'd like to see it as well Chad. Let's hope someone donates
one soon. ;-}
------------> MHB :-)
... OFFLINE 1.36 * Never sleep with anyone crazier than yourself.
--- DB B1063/001271
* Origin: * Bare Bones BBS * (1:105/360)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET