--> Set File Attributes by Delphi | Delphi Tips Trick

For Newbie

Tuesday, 15 November 2011

Set File Attributes by Delphi

| Tuesday, 15 November 2011
Tricks on how to change the attributes possessed by the file / folder.

Use the following functions:
SetFileAttributes function (lpFileName: PChar; dwFileAttributes: DWORD): BOOL;

Param dwFileAttributes which you can use:
FILE_ATTRIBUTE_ARCHIVE
FILE_ATTRIBUTE_HIDDEN
FILE_ATTRIBUTE_NORMAL
FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_SYSTEM
... Etc. / / you can see on Windows.pas

Example of use:
/ / Set Attributes to Normal
/ /! Eliminating all the attributes contained in the file / folder
SetFileAttributes (PChar (Edit1.Text), FILE_ATTRIBUTE_NORMAL);

/ / Set Attributes to Hidden + System
SetFileAttributes (PChar (Edit1.Text), FILE_ATTRIBUTE_HIDDEN or
                   FILE_ATTRIBUTE_SYSTEM);

/ / Set Attributes to Read-Only Archive +
SetFileAttributes (PChar (Edit1.Text), FILE_ATTRIBUTE_READONLY or
                   FILE_ATTRIBUTE_ARCHIVE);

/ / Set Attributes to Read-Only Archive + + Hidden + System
SetFileAttributes (PChar (Edit1.Text), FILE_ATTRIBUTE_READONLY or
                   FILE_ATTRIBUTE_ARCHIVE or FILE_ATTRIBUTE_HIDDEN or
                   FILE_ATTRIBUTE_SYSTEM);

Related Posts

No comments: