basicqbasicqb64

How To Trap Control-Alt-Delete In QB64


I am using the following code in QB64 to trap Control-Break:

ON TIMER(1) GOSUB breaktrap
TIMER ON
x = _EXIT ' disable break
DO
    _LIMIT 50
    x$ = INKEY$
LOOP
breaktrap:
v = _EXIT
IF v THEN
    PRINT "*break*"
    SLEEP 5
    SYSTEM
END IF
RETURN

I would like to know if there is a way to trap Control-Alt-Delete in QB64.


Solution

  • This snip describes why Control-Alt-Delete is not trapped:

    CONST KEY_RSHIFT& = 100303
    CONST KEY_LSHIFT& = 100304
    CONST KEY_RCTRL& = 100305
    CONST KEY_LCTRL& = 100306
    CONST KEY_RALT& = 100307
    CONST KEY_LALT& = 100308
    DO
        x = _KEYHIT
        IF x = CVI(CHR$(0) + CHR$(83)) THEN
            IF _KEYDOWN(KEY_RCTRL&) OR _KEYDOWN(KEY_LCTRL&) THEN
                IF _KEYDOWN(KEY_RALT&) OR _KEYDOWN(KEY_LALT&) THEN
                    PRINT "KEYHIT: Ctrl-Alt-Delete"
                ELSE
                    PRINT "KEYHIT: Ctrl-Delete"
                END IF
            ELSE
                IF _KEYDOWN(KEY_RALT&) OR _KEYDOWN(KEY_LALT&) THEN
                    PRINT "KEYHIT: Alt-Delete"
                ELSE
                    PRINT "KEYHIT: Delete"
                END IF
            END IF
        END IF
        k$ = INKEY$
    LOOP UNTIL k$ = CHR$(27)