简体   繁体   中英

Checking for permissions for SHBrowseForFolder similar to GetSaveFileName, C++ / Win32

I have a program that uses both SHBrowseForFolder, GetSaveFileName.

When I use GetSaveFileName and the directory chosen doesn't have the right permission it automatically shows an error that the current user doesn't have the proper permission.

I need a checking similar to this to happen when I use SHBrowseForFolder.

Have tried CreateDirectory but it succeeds if the directory chosen is C:, while GetSaveFileName would only allow admins to write here.

You can check permissions using this:

  1. GetProcessToken
  2. GetTokenInformation (to get the tokenuser and SID for the user)
  3. GetNamedSecurityInfo (to get the DACL for the given folder) and
  4. BuildTrusteeWithSid(pTrustee, pSidUser);
  5. GetEffectiveRightsFromAcl

For more details see Check User's Permissions On A File or Folder article.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM