SetFileSecurity(Win32 API)来设置NTFS上的 文件和目录的权限用法如下:BOOL SetFileSecurity(LPCTSTR lpFileName, // address of string for filenameSECURITY_INFORMATION SecurityInformation, // type of information to setPSECURITY_DESCRIPTOR pSecurityDescriptor // address of security descriptor);SECURITY_INFORMATION用于指示下面一个参数的类型, 它可以取如下的值:OWNER_SECURITY_INFORMATION文件和目录的所有者信息GROUP_SECURITY_INFORMATION主组信息DACL_SECURITY_INFORMATION自由的访问控制列表(ACL)信息SACL_SECURITY_INFORMATION系统的访问控制列表(ACL)信息请您参考下列API函数和数据结构以获得设置权限的进一步的信息:ACL (DataStructure, Access Control List)Get/SetSecurityDescriptorDaclGet/SetSecurityDescriptorGroupGet/SetSecurityDescriptorOwnerGet/SetSecurityDescriptorSacl
setFileAttributes好久没回答问题了。耗子,我要跟你抢分了。哈哈。
特意帮 帮楼住 找的。记得给我分!
我现在是想: 管理员通过程序把某个文件设为只读,当其他的用户 (比如Guest)进入时,再无法改变此文件.要想改动此文件只能通过管理员进入程序中设置此文件的属性
只能通過設置使用者的權限來限制吧
最好有个例子
文件和目录的权限用法如下:BOOL SetFileSecurity(LPCTSTR lpFileName, // address of string for filenameSECURITY_INFORMATION SecurityInformation, // type of information to setPSECURITY_DESCRIPTOR pSecurityDescriptor // address of security descriptor);SECURITY_INFORMATION用于指示下面一个参数的类型, 它可以取如下的值:OWNER_SECURITY_INFORMATION文件和目录的所有者信息GROUP_SECURITY_INFORMATION主组信息DACL_SECURITY_INFORMATION自由的访问控制列表(ACL)信息SACL_SECURITY_INFORMATION系统的访问控制列表(ACL)信息请您参考下列API函数和数据结构以获得设置权限的进一步的信息:ACL (DataStructure, Access Control List)Get/SetSecurityDescriptorDaclGet/SetSecurityDescriptorGroupGet/SetSecurityDescriptorOwnerGet/SetSecurityDescriptorSacl
SetFileSecurity
设置文件或目录安全属性
否
是
是