RegSetKeySecurity

  LONG RegSetKeySecurity(hkey, SecInf, pSecDesc)    
  HKEY hkey; /* open handle to key to set */
  SECURITY_INFORMATION SecInf; /* specifies descriptor contents */
  PSECURITY_DESCRIPTOR pSecDesc; /* descriptor to set for this key */

The RegSetKeySecurity function sets the security of a previously opened registration key.

Parameters

hkey

Specifies an open handle to the key to set the security for.

SecInf

Specifies a SECURITY_INFORMATION structure that indicates the contents of the supplied SECURITY_DESCRIPTOR.

pSecDesc

Points to the SECURITY_DESCRIPTOR to set for the specified key.

Return Value

The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.

Comments

This function is only successful if the following conditions are met:

If the key's owner or group is to be set, the caller must have WRITE_OWNER permission or have SeTakeOwnershipPrivilege.

If the key's DACL is to be set, the caller must have WRITE_DAC permission or be the object's owner.

If the key's SACL is to be set, the caller must have SeSecurityPrivilege.

See Also

RegGetKeySecurity