Henry Olive 5 Posted 10 hours ago Good Day I asked a similiar question while ago According to that replies i made below proc In my proc HIDDEN and NORMAL works but READONLY doesnt work even though i dont get any err.msg. what am i doing wrong ? Thank You procedure TFolders.RG1Click(Sender: TObject); var Attr : TFileAttributes; FolderPath : String; begin FolderPath:= CDS1FOLDERPATH.AsString; Attr:= TPath.GetAttributes(PChar(FolderPath)); if not TDirectory.Exists(FolderPath) then begin ShowMessage(FolderPath + ' not Exist'); Abort; end; if RG1.ItemIndex = 0 then // Read Only - RG1 = Radio Group SetFileAttributes(PChar(FolderPath), FILE_ATTRIBUTE_READONLY) else if RG1.ItemIndex = 1 then // Hidden SetFileAttributes(PChar(FolderPath), FILE_ATTRIBUTE_HIDDEN) else if RG1.ItemIndex = 2 then // Open (Not Read Only - Not Hidden) SetFileAttributes(PChar(FolderPath), FILE_ATTRIBUTE_NORMAL); end; Share this post Link to post
Remy Lebeau 1429 Posted 3 hours ago (edited) 7 hours ago, Henry Olive said: what am i doing wrong ? Nothing. ReadOnly has no meaning for a folder and is ignored. This is documented behavior: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileattributesw Quote FILE_ATTRIBUTE_READONLY 1 (0x1) ... This attribute is not honored on directories... Making a folder read-only is an illusion. When you do it in Explorer, it iterates the folder's files and updates them accordingly. You can't change the attribute on the folder itself. Doing so is reserved by Windows for its private use on system folders. You cannot view or change the Read-only or the System attributes of folders in Windows Server 2003, in Windows XP, in Windows Vista or in Windows 7 Edited 3 hours ago by Remy Lebeau Share this post Link to post