Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to make a file read only from program
Message
De
29/08/2003 17:35:42
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00824651
Message ID:
00824714
Vues:
24
Yuri,

Seems to me you're overwriting the other file attributes
#DEFINE FILE_ATTRIBUTE_READONLY 	0x01
#DEFINE FILE_ATTRIBUTE_HIDDEN		0x02
#DEFINE FILE_ATTRIBUTE_SYSTEM		0x04
#DEFINE FILE_ATTRIBUTE_DIRECTORY	0x10
#DEFINE FILE_ATTRIBUTE_ARCHIVE		0x20
#DEFINE FILE_ATTRIBUTE_NORMAL		0x80
#DEFINE FILE_ATTRIBUTE_TEMPORARY	0x0100

declare Integer GetFileAttributes in win32api string @
declare Integer SetFileAttributes in win32api string @, Integer

function FileSetReadOnly(FileName)
	local fa
	fa = GetFileAttributes(@FileName)
	
	if( fa == -1 )
		return FALSE
	endif
	
	fa = bitor(fa, FILE_ATTRIBUTE_READONLY)
	
	if( empty(SetFileAttributes(@FileName, fa)) )
		return FALSE
	endif
	
endfunc
*--------------------------------------------------------------------------
>#DEFINE FILE_ATTRIBUTE_READONLY 0x00000001
>DECLARE integer SetFileAttributes in Win32API ;
> string @cFile, integer nAttribs
>
>lcFile="C:\scanned2903.tif"
>?SetFileAttributes(@lcFile,FILE_ATTRIBUTE_READONLY)
>clear dlls
>
>>How can i make the file scanned.tif to read only. if it exists at the following path.
>>
>>"C:\scanned2903.tif"
>>
>>Thank you very much.
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform