Page 1 of 1

Ctrl + Break

Posted: Sun Jun 29, 2003 1:59 am
by SuperNova
I think most of you will know this.
How do I prevent people from using Ctrl + Break to exit the program?
Something with ON KEY, perhaps?
The protection has to be common, so during the entire program until it reaches the END command.

Re: Ctrl + Break

Posted: Thu Jul 03, 2003 4:43 pm
by Guest
'___i did find this, copy and paste
'Subject: DISABLE CTRL+BREAK Date: Year of 1995        
'Author: Daniel Trimble      Code: QB, QBasic, PDS      
'Origin: FidoNet QUIK_BAS Echo  Packet: KEYBOARD.ABC
'QBasic NoBreak v1.0a
'Copyright (c)1995 by Daniel Trimble
'Public Domain - use at your own risk.

CLS
DO
KEY 15, CHR$(4 + 128 + 32 + 64) + CHR$(70)
ON KEY(15) GOSUB NoBreak: KEY(15) ON
KEY 16, CHR$(4 + 128) + CHR$(70)
ON KEY(16) GOSUB NoBreak: KEY(16) ON
KEY 17, CHR$(4 + 128 + 32) + CHR$(70)
ON KEY(17) GOSUB NoBreak
KEY(17) ON: KEY 18, CHR$(4 + 128 + 64) + CHR$(70)
ON KEY(18) GOSUB NoBreak
KEY(18) ON: KEY 19, CHR$(4) + CHR$(70)
ON KEY(21) GOSUB NoBreak
KEY(21) ON: KEY 22, CHR$(4 + 64) + CHR$(70)
ON KEY(22) GOSUB NoBreak: KEY(22) ON
KEY 23, CHR$(4 + 32) + CHR$(46)
ON KEY(23) GOSUB NoBreak: KEY(23) ON
KEY 24, CHR$(4 + 64) + CHR$(46)
ON KEY(24) GOSUB NoBreak: KEY(24) ON
KEY 25, CHR$(4 + 32 + 64) + CHR$(46)
ON KEY(25) GOSUB NoBreak: KEY(25) ON

LOCATE 1, 1, 0: PRINT "QBasic NoBreak v1.0a"
PRINT "Copyright (c)1995 by Daniel Trimble"
LOCATE 4, 1, 0: PRINT "This program and all source is public domain.  I will not be responsible"
PRINT "for any damage this program may cause.  I am not at fault.  Use at your"
PRINT "own risk - period!"
LOCATE 15, 1, 0: PRINT "Try pressing either CTRL-BREAK or CTRL-C.  Nothing will happen."
PRINT "To end the program, hit ENTER."
IF INKEY$ = CHR$(13) THEN END
LOOP

NoBreak: RETURN
'ctrl=4 extended keys=128 numlock=32 c=46 capslock=64

Re: Ctrl + Break

Posted: Sat Jul 05, 2003 9:56 am
by Quentin
I am wondering why you would need such protection from people trying to get out of the programme - is it some sort of virus?

PS: Supernova - I like your avatar!

Re: Ctrl + Break

Posted: Sat Jul 05, 2003 5:36 pm
by SuperNova
I am writing a password protection program for my brothers' computer.

PS. Thanks!

Re: Ctrl + Break

Posted: Sun Jul 06, 2003 5:04 am
by Quentin
Ok.  That's good then. :)

Re: Ctrl + Break

Posted: Sat Jul 12, 2003 9:11 pm
by SuperNova
The code works only half.
When the computer starts up and you keep your finger on ctrl+break,
you can still 'break' the security.

Another question, how do I make qbasic set a DOS variable?
I mean the variables on the commandline and in batches.
Here's a simple example of such a batch.
Note that this is batch code and not qbasic code!

@ECHO OFF
CLS
ECHO Searching for eggs...
chicken=false
IF EXIST *.egg chicken=true
IF %chicken%==true goto gotcha
:gotcha
ECHO Found eggs!!!
DIR *.egg /b
IF %chicken%==false ECHO No eggs here...
PAUSE
CLS
chicken=


So in this example, I would like to set %chicken% in a qbasic environment.
But how?