[Note: solution has been found and posted - scroll down a few posts for download.]
Hi all,
I need a little help converting a C++ system call to Blitz3D. I don't think it should be a big deal, but I'm horrible at these things. If someone were willing to do this, I'd be happy to
a) paypal him/her $25 for games/pizza/beer/etc as a token of appreciation
b) post the resulting code here so that anyone else in the community can use it for free.
The code in question is related to giving Blitz programs full-write access to common user folders (this is almost a requirement for Vista, given that you simply can no longer write to the "Program Files" directory without resulting in files being virtualized and other headaches).
The code itself is used in a BlitzMax version by Grey Alien, and is discussed here:
http://www.blitzbasic.co.nz/Community/posts.php?topic=73305
(and yes, I've asked for Grey's permission to do this before posting here)
Specifically, I need the B3d equivalent of this C++ code (or a way to run this from Blitz3D the way Grey runs it from BlitzMax):
[CODE]
#include <windows.h>
#include <aclapi.h>
extern "C" bool GiveDirectoryUserFullAccess(LPCTSTR lpPath)
{
HANDLE hDir = CreateFile(lpPath,READ_CONTROL|WRITE_DAC,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
if(hDir == INVALID_HANDLE_VALUE) return false;
ACL* pOldDACL=NULL;
SECURITY_DESCRIPTOR* pSD = NULL;
GetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,&pOldDACL,NULL,&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;
}
[/CODE]
The code is designed to set a directory to "full access", which is required for other users to write/modify files originally created on a different user profile.
If you can do this, please let me know (e-mail to midnight@...).
Cheers,
Patrick
Hi all,
I need a little help converting a C++ system call to Blitz3D. I don't think it should be a big deal, but I'm horrible at these things. If someone were willing to do this, I'd be happy to
a) paypal him/her $25 for games/pizza/beer/etc as a token of appreciation
b) post the resulting code here so that anyone else in the community can use it for free.
The code in question is related to giving Blitz programs full-write access to common user folders (this is almost a requirement for Vista, given that you simply can no longer write to the "Program Files" directory without resulting in files being virtualized and other headaches).
The code itself is used in a BlitzMax version by Grey Alien, and is discussed here:
http://www.blitzbasic.co.nz/Community/posts.php?topic=73305
(and yes, I've asked for Grey's permission to do this before posting here)
Specifically, I need the B3d equivalent of this C++ code (or a way to run this from Blitz3D the way Grey runs it from BlitzMax):
[CODE]
#include <windows.h>
#include <aclapi.h>
extern "C" bool GiveDirectoryUserFullAccess(LPCTSTR lpPath)
{
HANDLE hDir = CreateFile(lpPath,READ_CONTROL|WRITE_DAC,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
if(hDir == INVALID_HANDLE_VALUE) return false;
ACL* pOldDACL=NULL;
SECURITY_DESCRIPTOR* pSD = NULL;
GetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,&pOldDACL,NULL,&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;
}
[/CODE]
The code is designed to set a directory to "full access", which is required for other users to write/modify files originally created on a different user profile.
If you can do this, please let me know (e-mail to midnight@...).
Cheers,
Patrick