Check/uncheck the read-only attribute of an file from Progress

Hi all

Does anyone know how I could check/uncheck the read-only attribute of a file, eg a PDF document, on the fly from my Progress 9.1 application under Windows XP?

I am managing many application related files lilke pdf documents, jpg images and the like that I link to db records and display on screens, etc in my application. I want to make sure that as I create/import these files they are flagged to read-only under XP to help avoid accidental deletion by errant users accessing the various directories directly via Explorer.

Cheers in advance
Chris

PS I am also a total moron :rolleyes: when it comes to digging deeper than the Progress environment so any simple way without having to delve in APIs and OCXs would be most excellent!
 
here's an excerpt from a win api library i wrote a while back

there's no comments, but you can look'em up @msdn.com. hth



<snippet>

/* libraries */

&glob kernel "kernel32"
&glob shell "shell32"
&glob user "user32"

/* generic values */

&glob null 0
&glob invalid_handle_value -1



/* createfile dwDesiredAccess */

&glob generic_execute 536870912
&glob generic_write 1073741824
&glob generic_read -2147483648

/* createfile dwShareMode */

&glob file_share_read 1
&glob file_share_write 2
&glob file_share_delete 4

/* createfile dwCreationDisposition */

&glob create_always 2
&glob create_new 1
&glob open_always 4
&glob open_existing 3
&glob truncate_existing 5

/* createfile dwFlagsandAttributes */

&glob file_attribute_normal 128
&glob file_flag_delete_on_close 67108864



procedure CloseHandle external {&kernel}:

define input param hObject as long.
define return param ReturnValue as long.

end procedure. /* CloseHandle */

procedure CreateFileA external {&kernel}:

define input param lpFileName as char.
define input param dwDesiredAccess as long.
define input param dwShareMode as long.
define input param lpSecurityAttributes as long.
define input param dwCreationDisposition as long.
define input param dwFlagsAndAttributes as long.
define input param hTemplateFile as long.
define return param ReturnValue as long.

end procedure. /* CreateFileA */



function FileLocked return logical ( pcFileName as char ):

define var hFile as int no-undo.

run lockFile( pcFileName, output hFile ).

run releaseFile( hFile ).

return hFile = {&invalid_handle_value}.

end function. /* FileLocked */



procedure lockFile:

define input param pcFileName as char no-undo.
define output param phFileHndl as int no-undo.

run CreateFileA(
pcFileName,
{&generic_write},
{&null},
{&null},
{&open_existing},
{&file_attribute_normal},
{&null},
output phFileHndl ).

end procedure. /* lockFile */

procedure releaseFile:

define input param phFileHndl as int no-undo.

define var iRetVal as int no-undo.

run CloseHandle( phFileHndl, output iRetVal ).

end procedure. /* releaseFile */



define var hFile as int no-undo.

run lockFile( "c:\test.txt", output hFile ).

os-delete c:\test.txt.

run releaseFile( hFile ).

</snippet>
 
Back
Top