RT.例如该文件夹为D:\abc。
我想知道当前运行的用户有无在D:\abc这个文件夹里面创建文件的权限。

解决方案 »

  1.   

    这个函数用起来比较复杂。简单的方式是你用CreateFile直接在目录下创建文件,看返回错误码是拒绝访问或没有权限来测试。
      

  2.   

    函数AddAccessRights实现为文件(目录)添加一个帐户(组)的权限函数GetAccountRights实现获取该文件(目录)指定帐户(组)的权限  BOOL WINAPI GetFileSecurity(
      __in       LPCTSTR lpFileName,
      __in       SECURITY_INFORMATION RequestedInformation,
      __out_opt  PSECURITY_DESCRIPTOR pSecurityDescriptor,
      __in       DWORD nLength,
      __out      LPDWORD lpnLengthNeeded
    );DWORD WINAPI GetNamedSecurityInfo(
      __in LPTSTR pObjectName,
      __in SE_OBJECT_TYPE ObjectType,
      __in SECURITY_INFORMATION SecurityInfo,
      __out_opt PSID *ppsidOwner,
      __out_opt PSID *ppsidGroup,
      __out_opt PACL *ppDacl,
      __out_opt PACL *ppSacl,
      __out_opt PSECURITY_DESCRIPTOR *ppSecurityDescriptor
    );BOOL WINAPI GetSecurityDescriptorOwner
    ( __in PSECURITY_DESCRIPTOR pSecurityDescriptor,
     __out PSID* pOwner, __out LPBOOL lpbOwnerDefaulted );GetSecurityDescriptorControl
    GetSecurityDescriptorDacl
    GetSecurityDescriptorGroup
    GetSecurityDescriptorLength
    GetSecurityDescriptorOwner
    GetSecurityDescriptorRMControl
    GetSecurityDescriptorSacl
    InitializeSecurityDescriptor
    IsValidSecurityDescriptor
    SetSecurityDescriptorDacl
    SetSecurityDescriptorGroup
    SetSecurityDescriptorOwner
    SetSecurityDescriptorRMControl
    SetSecurityDescriptorSacl这些应该够用了 lz
      

  3.   

    这个方式简单是简单,但是如果你创建成功的话,会在目录出现一个测试用权限用的文件。
    然后需要使用DeleteFile来删除,但是这个删除会在回收站出现。
    必须通过什么方法来直接删除(不经过回收站)呢?
      

  4.   

    DeleteFile是直接删除的啊,咋会到回收站里,没遇到过。