Qbasicnews.com

Full Version: Files protection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I don't remember how can Qbasic remove any file protection ... ?

I mean READ or WRITE protection
You mean readonly files?

You can remove the readonly attribute like this:

Code:
'$INCLUDE:'QB.BI'
DEFINT A-Z

SUB DeleteReadOnly (FileName AS STRING)
   DIM Regs AS RegTypeX
   Regs.ax = &H4300
   Regs.ds = -1
   fl$ = FileName + CHR$(0)
   Regs.dx = SADD(fl$)
   INTERRUPTX &H21, Regs, Regs
   Regs.cx = Regs.cx AND &HFFFE&
   Regs.ax = &H4301
   Regs.ds = -1
   Regs.dx = SADD(fl$)
   INTERRUPTX &H21, Regs, Regs
END SUB
Or use SHELL to call DOS's ATTRIB...
THX Neo

Antoni ?? What do you mean ?
I don't know these DOS's Attributes
In DOS commandline...

ATTRIB [+R|-R] [+A|-A] [+S|-S] [+H|-H][[unit:][path]fliename][/S]

...where...

+R sets READONLY attribute, -R removes it
+A sets ARCHIVE attribute (read/write flag), -A removes it
+S sets SYSTEM attribute, -S removes it
+H sets HIDDEN attribute, -H removes it

...and...

/S to process files in the current directory/folder and in all its subdirectories.

So, in your case:

SHELL "ATTRIB -R filename.ext"

...and that's all.
Smile I prefer my code, else I would have a black screen coming through my program at every SHELL call. Wink