1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
| Success := InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION);
If Success Then if GetAccountSid( '' , 'UserName' , UID) then begin sACL := (2 * SizeOf(ACCESS_ALLOWED_ACE)) + (2 * GetLengthSid(UID)) - (2 * SizeOf(DWORD)); pNewAcl := HeapAlloc(GetProcessHeap, HEAP_ZERO_MEMORY, sACL); if pNewAcl <> NIL then if InitializeAcl(pNewAcl^, sACL, ACL_REVISION) then if AddAccessAllowedAce(pNewAcl^, ACL_REVISION, GENERIC_ALL, UID) then if not SetSecurityDescriptorDacl(psd, TRUE, pNewAcl, FALSE) then Exit; end; end else Success := SetSecurityDescriptorDacl(pSD, TRUE, NIL, FALSE);
sa.nLength := sizeof(sa); sa.lpSecurityDescriptor := pSD; sa.bInheritHandle := FALSE;
if pNewAcl <> nil then HeapFree(GetProcessHeap, 0, pNewAcl); |