从代码中将文件设置为只读,并且也不允许从属性中更改它
我想将文件更改为仅从我的应用程序中读取。 为此,我使用了
SetFileAttributes(szFile, FILE_ATTRIBUTE_READONLY);
并且有效。 但是,可以通过右键单击文件从文件属性更改只读属性。
但我也想阻止它......
在使文件只读后,是否可以禁用文件属性中的只读复选框。
如果可能的话怎么办..?
请帮助我...
提前致谢...
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, after making the file readonly.
if possible how it could be done..?
please help me...
Thanks in advance....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要为每个人设置读取权限。例如,请参阅 SetNamedSecurityInfo 函数。或者 Cacls 实用程序。
You need to set Read Permissions to everyone. See for example SetNamedSecurityInfo function. Or Cacls utility.
你不能这样做。如果用户帐户具有足够的权限,那么无论您的程序可以执行什么操作,其他程序(例如 Windows 资源管理器及其文件属性)也可以执行。但是,如果用户被限制为受限用户帐户,则可以在文件上设置安全描述符以防止用户修改属性。
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.