procedure TForm1.Button5Click(Sender: TObject);
//LIMIT_CONTROL
const
FULL_CONTROL = $001F01FF;
READ_EXEC_CONTROL = $001200A9;
LIMIT_CONTROL = $001000A9;
MODIFY_CONTROL = $001301BF;
var
path:
string;
pNewDACL : PACL;
EA :
array [0..5]
of EXPLICIT_ACCESS;
begin
path:='
G:\';
ZeroMemory(@EA,6*Sizeof(EXPLICIT_ACCESS));
BuildExplicitAccessWithName(@EA[0], PChar('
USER'), LIMIT_CONTROL , SET_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT);
BuildExplicitAccessWithName(@EA[2], PChar('
IUSR_<COMPUTERNAME>'), MODIFY_CONTROL , SET_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT);
// access for other user
BuildExplicitAccessWithName(@EA[4], PChar('
SYSTEM'),LIMIT_CONTROL , SET_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT);
SetEntriesInAcl(1, @EA[0],
nil, pNewDACL);
SetEntriesInAcl(1, @EA[2], pNewDACL, pNewDACL);
SetEntriesInAcl(1, @EA[4], pNewDACL, pNewDACL);
SetNamedSecurityInfo(PChar(path), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION,
NIL,
NIL, pNewDACL,
NIL);
end;
procedure TForm1.Button6Click(Sender: TObject);
//FULL_CONTROL
const
FULL_CONTROL = $001F01FF;
READ_EXEC_CONTROL = $001200A9;
LIMIT_CONTROL = $001000A9;
MODIFY_CONTROL = $001301BF;
var
path:
string;
pNewDACL : PACL;
EA :
array [0..5]
of EXPLICIT_ACCESS;
begin
path:='
G:\';
ZeroMemory(@EA,6*Sizeof(EXPLICIT_ACCESS));
BuildExplicitAccessWithName(@EA[0], PChar('
USER'), FULL_CONTROL,SET_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT);
BuildExplicitAccessWithName(@EA[2], PChar('
IUSR_<COMPUTERNAME>'), MODIFY_CONTROL , SET_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT);
// access for other user
BuildExplicitAccessWithName(@EA[4], PChar('
SYSTEM'),FULL_CONTROL,SET_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT);
SetEntriesInAcl(1, @EA[0],
nil, pNewDACL);
SetEntriesInAcl(1, @EA[2], pNewDACL, pNewDACL);
SetEntriesInAcl(1, @EA[4], pNewDACL, pNewDACL);
SetNamedSecurityInfo(PChar(path), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION,
NIL,
NIL, pNewDACL,
NIL);
end;