Is it possible to change a file from read only and back in Blitz 3d?
read only files
Blitz3D Forums/Blitz3D Programming/read only files Yes you can ( be careful - I checked it and it worked - don't test your own values ;-) don't know the result other than using Bits 0 1 2 5 and 8 )
The first 3 lines go into Userlib\kernel32.decls (without the leading semicolon and without lines that already exist)
The first 3 lines go into Userlib\kernel32.decls (without the leading semicolon and without lines that already exist)
;.lib "kernel32.dll" ;GetFileAttributes%(filename$):"GetFileAttributesA" ;SetFileAttributes(FileName$,param):"SetFileAttributesA" ;param 1=ReadOnly 2=Hidden 4=System 16=ADirectory 32=Archive 128=NoOtherAtrributes 2048=CompressedFileOrDir Graphics 800,600,0,2 Fil$="TestFile.txt" f=WriteFile(Fil$) WriteLine f,"Test - This is a Test" CloseFile f Print "New File written" Attrib=GetFileAttributes(Fil$) Print GetAttribS$(Attrib) SetFileAttributes(Fil$,Attrib Or 1) Print "Set to ReadOnly (Other Bits are kept)" Attrib=GetFileAttributes(fil$) Print GetAttribS$(Attrib) SetFileAttributes(Fil$, Attrib Or 1 Or 2 Or 4) Print "Set to ReadOnly Hidden and System (Other Bits are kept)" Attrib=GetFileAttributes(Fil$) Print GetAttribS$(Attrib) SetFileAttributes(Fil$, 128) Print "Set to nothing" Attrib=GetFileAttributes(Fil$) Print GetAttribS$(Attrib) WaitKey() End Function GetAttribS$(a) If (a And 1) = 1 Then o$="R" Else o$="-" If (a And 2) = 2 Then o$=o$+"H" Else o$=o$+"-" If (a And 4) = 4 Then o$=o$+"S" Else o$=o$+"-" If (a And 32) = 32 Then o$=o$+"A" Else o$=o$+"-" ;the following not seen in action yet If (a And 16) = 16 Then o$=o$+"D" Else o$=o$+"-" If (a And 2048) = 2048 Then o$=o$+"C" Else o$=o$+"-" Return o$ End Function
Thansk for you help!