Page 1 of 1

stopping access

Posted: Sat Oct 09, 2004 5:06 pm
by =D
<p>
Ok well how would i go about stoping access to a text file that is use in my QBASIC program? can be this be done?

Posted: Sat Oct 09, 2004 5:53 pm
by {Nathan}
like this, lets say you have opened file #1 and are ready to close it. Hence the close.

CLOSE #1

like that, or

CLOSE#n
Where n is the file number[/i]

re

Posted: Sat Oct 09, 2004 6:47 pm
by =D
Let me say that again , what i ment was is ther a way to stop people getting into this text file, like can on opening of the text file it opens a QB file witch closes it, i could make this text file hyper text so is ther any html code that opens a file on load?



Posted: Sat Oct 09, 2004 10:56 pm
by barok
You're being very unclear. Try again. Use proper punctuation, use something else instead of red, which clashes with white, and try to make your message understandable.

What you are asking for is impossible. You want a program that prevents people from accessing a file. The best thing to do is encrypt the file. Encrypting will make the file unreadable to anyone without the decrypter. Or you could save as binary, you could compress the file into your own format, or at the least you could rename the extension. for example, instead of file.txt you could have file.dat.

Posted: Sun Oct 10, 2004 8:11 am
by Guest
i have come up with this code below but when u test it, it says file alredy open but i closed it can someone help

Code: Select all

CLS
OPEN "mac.dat" FOR INPUT AS #1
  INPUT #1, S$
  PRINT S$
IF S$ = "****  BLOCKED  ****" THEN GOTO 12 ELSE GOTO 13
CLOSE #1





13 : PRINT "** THIS PROGRAM IS PASSWORD PROTECTED **"

PRINT "*  ENTER PASSWORD  *"
INPUT pass$
IF pass$ = "king" THEN GOTO 1 ELSE GOTO 3




3 PRINT "***  FAIL  ***"
PRINT "**  ENTER PASSWROD  **"

INPUT pass$
IF pass$ = "king" THEN GOTO 1 ELSE GOTO 4
4 PRINT "**  FAIL **"
PRINT "***  ENTER PASSWORD  ***"
INPUT pass$
IF pass$ = "king" THEN GOTO 1 ELSE GOTO 5
5
12 :
OPEN "file.txt" FOR OUTPUT AS #1
  PRINT #1, "****  BLOCKED  ****"
  CLOSE #1

PRINT "********* BLOCKED **********"

END






1 PRINT "** Access Granted **"

END


  


Posted: Sun Oct 10, 2004 8:15 am
by Guest
ooops were it says file.txt thats ment to be mac.dat but this still dose not solve my probmlem

Posted: Sun Oct 10, 2004 11:41 am
by barok
use freefile instead of just choosing #1. using this you can avoid this.

number = freefile

open "file.txt" for input as #number


ugh... spaghetti code. that's something you really want to avoid.

btw, did you hear me? what your asking for is impossible with qb!

Posted: Sun Oct 10, 2004 12:37 pm
by Guest
hmm ok i will give that ago and yes i no what u said so i have gone off that idea this is something new .... 1 more thing if u could help me would be to tell me how to turn my files into banary?? ty

Posted: Sun Oct 10, 2004 1:20 pm
by barok
first, open the file. then copy all of it's contents into variables. then open the file for binary:

open "file.txt" for binary as #filenum

and save all the contents.

Posted: Sun Oct 10, 2004 5:15 pm
by Z!re
Well, it can be done in QB.

You have a file, that is encrypted.

If the file is missing, lock down the program.
If the unencrypted thing says "locked" lock down the program.

Most secure you can go.


Or you could just store the file in let's say:
C:\Windows\System\MSWDLL.DRV

Or some other equally cryptic name.

Just make sure to store the path as CHR$() statements and not plaintext, as plaintext can be easily found.

Posted: Tue Oct 12, 2004 4:09 pm
by Digital Shadow
carefull with that open as output, that erases the file and remakes it, look into APPEND, unless thats what you want...

Posted: Tue Oct 12, 2004 4:17 pm
by Digital Shadow
and optimize that spag...

Code: Select all

CLS

OPEN "mac.dat" FOR INPUT AS #1
  INPUT #1, S$ 
  PRINT S$ 
  IF S$ = "****  BLOCKED  ****" THEN GOTO Block ELSE GOTO Pass 
CLOSE #1

Pass: 
  PRINT "** THIS PROGRAM IS PASSWORD PROTECTED **" 
  For a=1 to 3
    PRINT "*  ENTER PASSWORD  *" 
    INPUT pass$ 
    IF pass$ = "king" THEN GOTO Access
    PRINT "***  FAIL  ***"
  NEXT a 

Block: 
  OPEN "file.txt" FOR OUTPUT AS #1 
    PRINT #1, "****  BLOCKED  ****" 
  CLOSE #1 
  PRINT "********* BLOCKED **********" 
  END 

Access:
  PRINT "** Access Granted **" 
  END 
ahh.... much better[/code]