For Newbie

Tuesday, 15 November 2011

Set File Attributes by Delphi

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);

Share on Facebook
Share on Twitter
Share on Google+

Related : Set File Attributes by Delphi