1. file attributes

Here's a simple program that modifies it's own file attributes.
The only REAL use I can see for these functions is to protect your
program's .ini file from being modified by the 'casual' user, and possibly
messing up your program.
...'hide' it, and maybe clear the write-only flag before opening it, then
set it during program exit.

--start code--
include win32lib.ew
without warning
atom junk, file_id_ptr, attribs


--FILE_ATTRIBUTE_READONLY = 1
--FILE_ATTRIBUTE_HIDDEN = 2
--FILE_ATTRIBUTE_ARCHIVE = 32
--FILE_ATTRIBUTE_NORMAL = 128


global constant Win =
create(Window,"file-attributes",0,0,0,200,200,0),
Label1  = create(LText,"current attributes",Win,10,10,180,20,0),
Check1  = create(CheckBox," Read-Only (1)",Win,10,40,150,20,0),
Check2  = create(CheckBox," Hidden (2)",Win,10,70,150,20,0),
Check3  = create(CheckBox," Archive (32)",Win,10,100,150,20,0),
Button1 = create(PushButton,"Change",Win,50,130,100,25,0),
--**
),
,C_LONG)

procedure onLoad_Win()

file_id_ptr=allocate_string("attrib.exw")
junk=c_func(zGetFileAttributes,{file_id_ptr})
setText(Label1,"current attributes = " & sprintf("%d",junk))
free(file_id_ptr)

end procedure

procedure set_attribs()
attribs=0

if isChecked(Check1) then attribs=attribs+1 end if
if isChecked(Check2) then attribs=attribs+2 end if
if isChecked(Check3) then attribs=attribs+32 end if
file_id_ptr=allocate_string("attrib.exw")
junk=c_func(zGetFileAttributes,{file_id_ptr})
setText(Label1,"current attributes = " & sprintf("%d",junk))
free(file_id_ptr)

end procedure

onOpen[ Win ] = routine_id( "onLoad_Win" )
onClick[Button1] = routine_id( "set_attribs")
WinMain( Win, Normal )
--end code--

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu