Make a file Readonly from code, and also doesnt allow to change it from the Properties
I would like to change a file to read only from my application. For that i have used,
SetFileAttributes(szFile, FILE_ATTRIBUTE_READONLY);
And worked. But the readonly property could be changed from the file properties on right clicking the file.
But I would like to block that too...
Is it possible to disable the Read-Only check-box in the file-properties, af开发者_运维知识库ter making the file readonly.
if possible how it could be done..?
please help me...
Thanks in advance....
You need to set Read Permissions to everyone. See for example SetNamedSecurityInfo function. Or Cacls utility.
You can't do this. If the user account has sufficient privileges, then whatever your program can do, other programs (like Windows Explorer and its file properties) can do as well. However if the user is restricted to a limited user account, you can set the security descriptor on the file to prevent the user from modifying the attributes.
精彩评论