Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to set file attribute?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00823333
Message ID:
00823390
Vues:
17
>>I found this API to set a file attribute
>>
>>
>>
DECLARE SHORT SetFileAttributes IN kernel32;
>>    STRING lpFileName,;
>>    INTEGER dwFileAttributes
>>
>>
>>I assume I set lpFilename to xyz.doc
>>but what do I set dwFileAttributes to make xyz.doc read only?

>
>Peter
>
>Another way is by using WSH:
>
>#define READONLY 1
>#define HIDDEN 2
>#define SYSTEM 4
>#define ARCHIVE 32
>oFSO = CreateObject("Scripting.FileSystemObject")
>oFile = oFSO.GetFile("c:\xyz.doc")
>oFile.Attributes = READONLY && changes to RO
>
Alex,

It's better to use the bit manipulation functions. This is because on of the file attribute bits is, itself, read-only (FILE_ATTRIBUTE_DIRECTORY 0x10) and may cause an error. Further, setting the attributes directly clears the other bits such as the archive bit.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform