views:

201

answers:

1

My C++ application stores some common user data in %CSIDL_COMMON_APPDATA%\Company\Product. I want to make sure the Users group has write permisions to this folder which on Vista it does not. How would do I do this?

+2  A: 

Figured it out myself using ATL...

CDacl oDacl;
AtlGetDacl(strFolder, SE_FILE_OBJECT, &oDacl);
oDacl.RemoveAces(Sids::Users()); // Remove existing "Users" access
oDacl.AddAllowedAce(Sids::Users(), FILE_ALL_ACCESS, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE);
AtlSetDacl(strFolder, SE_FILE_OBJECT, oDacl);

Of course my real code contains error checking.

Charles
Too bad I can't mark my own answer as "accepted"
Charles