FileAttributes
Several Kernel32 functions require specification or return of file attributes.
The attributes are stored in a single byte, with each bit of the byte representing a specific attribute (actually, only six bits are used of the eight in the byte). Each bit that is set to a one means that the file has that attribute turned on. The following are the attributes and the bits they use in the attribute byte:
| DECIMAL |
HEXADECIMAL |
ATTRIBUTE |
| 0 |
00000000 |
Read-Write |
| 1 |
00000001 |
Read-Only |
| 2 |
00000010 |
Hidden |
| 4 |
00000100 |
System |
| 8 |
00001000 |
Volume Label |
| 16 |
00010000 |
Directory |
| 32 |
00100000 |
Archive |
The attribute bits are summed to form the attribute byte. So, the attribute byte for a hidden, read-only directory would be 00010011h or 19. To insure that you don't mistakenly change an attribute, you should get the current attribute byte, change the bits as desired, then set the attribute byte.
To get the FileAttributes of a file you can do the following call:
Update v-DecimalAttributes = CallDLLS ('Kernel32.GetFileAttributesA','A4',v-Filename)
To set the FileAttributes of a file you can do the following call:
Update v-Result = CallDLLS ('Kernel32.SetFileAttributesA','A44',v-Filename,v-AttributesNumber)
There are no comments on this page. [Add comment]