private static void GrantAccess(IdentityReference account, NoopSafeHandle handle, int accessMask) { GenericSecurity security = new GenericSecurity(false, ResourceType.WindowObject, handle, AccessControlSections.Access); security.AddAccessRule(new GenericAccessRule(account, accessMask, AccessControlType.Allow)); security.Persist(handle, AccessControlSections.Access); }
private static void GrantAccess(SecurityIdentifier account, IntPtr handle, int accessMask) { SafeHandle safeHandle = new NoopSafeHandle(handle); GenericSecurity security = new GenericSecurity(false, ResourceType.WindowObject, safeHandle, AccessControlSections.Access); security.AddAccessRule( new GenericAccessRule(account, accessMask, AccessControlType.Allow)); security.Persist(safeHandle, AccessControlSections.Access); }