Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Set file readonly
Message
De
04/12/2017 02:08:29
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Divers
Thread ID:
01656088
Message ID:
01656090
Vues:
50
>I want to set a file from read-write to read-only and copy the following code (from Google) to my program, but failed. Anyone can point out what is wrong?
>
>TIA
>Ben
>
>*--------------------------------------------
>FUNC changeattr
>DECLARE INTEGER SetFileAttributes IN kernel32 STRING @,INTEGER @
>PRIVATE cFn
>cFilename="e:\testingfa\testfile.txt"
>#DEFINE FILE_ATTRIBUTE_READONLY 0x1
>m=SetFileAttributes(@cFilename,FILE_ATTRIBUTE_READONLY)
>RETURN m
FUNCTION SetAttr
PARAMETER tFileName, tAttribute
tAttribute = UPPER(tAttribute)
Private nAttribute
nAttribute=0
If 'S'$tAttribute && System
   nAttribute = nAttribute + 4
Endif    
If 'H'$tAttribute && Hidden
   nAttribute = nAttribute + 2
Endif    
If 'R'$tAttribute && ReadOnly
   nAttribute = nAttribute + 1
Endif    
If 'A'$tAttribute && Archive
   nAttribute = nAttribute + 32
Endif    
If 'N'$tAttribute && Normal
   nAttribute = nAttribute + 128
Endif    
declare integer SetFileAttributes IN kernel32 STRING, INTEGER 
Return SetFileAttributes(tFileName,nAttribute)=1
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform