可以使用SetFilePermission (Win32 API)来设置NTFS上的文件和目录的权限
用法如下:
BOOL SetFilePermission(LPCTSTR lpFileName, // address of string for filename
SECURITY_INFORMATION SecurityInformation, // type of information to set
PSECURITY_DESCRIPTOR pSecurityDescriptor // address of security descriptor
); 请您参考下列API函数和数据结构以获得设置权限的进一步的信息:
ACL (DataStructure, Access Control List)
Get/SetSecurityDescriptorDacl
Get/SetSecurityDescriptorGroup
Get/SetSecurityDescriptorOwner
Get/SetSecurityDescriptorSacl另外, 就是用GetFilePermission 

解决方案 »

  1.   

    你上面的SetFilePermission我找不到,应该是setfilesecurity吧,但是在setfilesecurity中的psecuritydescriptor中有些参数的意义我不清楚是什么意思,如:Revision,Sbz1,Control等,请指教。
    typedef struct _SECURITY_DESCRIPTOR {
      BYTE Revision;
      BYTE Sbz1;
      SECURITY_DESCRIPTOR_CONTROL Control;
      PSID Owner;
      PSID Group;
      PACL Sacl;
      PACL Dacl;
    } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR, PSECURITY
      

  2.   

    帮你找一个,自己试试可以使用SetFilePermission (Win32 API)来设置NTFS上的
    文件和目录的权限
    用法如下:
    BOOL SetFilePermission(LPCTSTR lpFileName, // address of string for filename
    SECURITY_INFORMATION SecurityInformation, // type of information to set
    PSECURITY_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/SetSecurityDescriptorDacl
    Get/SetSecurityDescriptorGroup
    Get/SetSecurityDescriptorOwner
    Get/SetSecurityDescriptorSacl另外, 就是GetFilePermission, :)