<PackageReference Include="Microsoft.Win32.Registry" Version="4.6.0-preview.19073.11" />

RegistrySecurity

public sealed class RegistrySecurity : NativeObjectSecurity
Represents the Windows access control security for a registry key. This class cannot be inherited.

Initializes a new instance of the RegistrySecurity class with default values.

Searches for a matching access control with which the new rule can be merged. If none are found, adds the new rule.

public void AddAuditRule(RegistryAuditRule rule)

Searches for an audit rule with which the new rule can be merged. If none are found, adds the new rule.

Searches for an access control rule with the same user and AccessControlType (allow or deny) as the specified access rule, and with compatible inheritance and propagation flags; if such a rule is found, the rights contained in the specified access rule are removed from it.

Searches for all access control rules with the same user and AccessControlType (allow or deny) as the specified rule and, if found, removes them.

Searches for an access control rule that exactly matches the specified rule and, if found, removes it.

Searches for an audit control rule with the same user as the specified rule, and with compatible inheritance and propagation flags; if a compatible rule is found, the rights contained in the specified rule are removed from it.

Searches for all audit rules with the same user as the specified rule and, if found, removes them.

Searches for an audit rule that exactly matches the specified rule and, if found, removes it.

Removes all access control rules with the same user as the specified rule, regardless of AccessControlType, and then adds the specified rule.

Removes all access control rules with the same user and AccessControlType (allow or deny) as the specified rule, and then adds the specified rule.

public void SetAuditRule(RegistryAuditRule rule)

Removes all audit rules with the same user as the specified rule, regardless of the AuditFlags value, and then adds the specified rule.