Ctrl + Break

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
SuperNova
Jr. Member
Posts:17
Joined:Sun Jun 08, 2003 11:49 pm
Location:Netherlands
Contact:
Ctrl + Break

Post by SuperNova » Sun Jun 29, 2003 1:59 am

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.

Guest

Re: Ctrl + Break

Post by Guest » Thu Jul 03, 2003 4:43 pm

'___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

Quentin
Newbie
Posts:2
Joined:Sat Jul 05, 2003 9:06 am
Location:Christchurch, SI., New Zealand

Re: Ctrl + Break

Post by Quentin » Sat Jul 05, 2003 9:56 am

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!
qramck@xtra.co.nz

SuperNova
Jr. Member
Posts:17
Joined:Sun Jun 08, 2003 11:49 pm
Location:Netherlands
Contact:

Re: Ctrl + Break

Post by SuperNova » Sat Jul 05, 2003 5:36 pm

I am writing a password protection program for my brothers' computer.

PS. Thanks!

Quentin
Newbie
Posts:2
Joined:Sat Jul 05, 2003 9:06 am
Location:Christchurch, SI., New Zealand

Re: Ctrl + Break

Post by Quentin » Sun Jul 06, 2003 5:04 am

Ok.  That's good then. :)
qramck@xtra.co.nz

SuperNova
Jr. Member
Posts:17
Joined:Sun Jun 08, 2003 11:49 pm
Location:Netherlands
Contact:

Re: Ctrl + Break

Post by SuperNova » Sat Jul 12, 2003 9:11 pm

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?

Post Reply