I was given then following C++ code by Indiepath which changes the folder permissions (I want to use it with Vista):
bool CgeneralFuncs::CreateDirectoryUserFullAccess(LPCTSTR lpPath)
{
int f = CreateDirectory(lpPath,NULL);
if(!f)
return false;
HANDLE hDir = CreateFile(lpPath,READ_CONTROL|WRITE_DAC,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
if(hDir == INVALID_HANDLE_VALUE)
return true;
ACL* pOldDACL=NULL;
SECURITY_DESCRIPTOR* pSD = NULL;
GetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,&pOldDACL,NULL,(void**)&pSD);
EXPLICIT_ACCESS ea={0};
ea.grfAccessMode = GRANT_ACCESS;
ea.grfAccessPermissions = GENERIC_ALL;
ea.grfInheritance = CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE;
ea.Trustee.TrusteeType = TRUSTEE_IS_GROUP;
ea.Trustee.TrusteeForm = TRUSTEE_IS_NAME;
ea.Trustee.ptstrName = TEXT("Users");
ACL* pNewDACL = NULL;
SetEntriesInAcl(1,&ea,pOldDACL,&pNewDACL);
SetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,pNewDACL,NULL);
LocalFree(pSD);
LocalFree(pNewDACL);
CloseHandle(hDir);
return true;
}
I've spent all try trying to convert it into BMax by using Externs and Types instead of structures etc. Got pretty far but got stuck on passing an array of types into a function (see recent thread).
Anyway, perhaps there's a different way. Can this source code be included (and compiled) in with my BMax project somehow so I can call it as an extern function? OR can it be turned into a Dll that I can call from Bmax instead?
Any ideas, I've basically got nuts today trying to do this...
|