This article was previously published under Q111546
This article has been archived. It is offered "as is" and will no longer be updated.
To take ownership of a registry key it is necessary to have a handle to thekey. A handle to the key can be obtained by opening the key with a registryAPI (application programming interface) such as RegOpenKeyEx(). If the userdoes not have access to the registry key, the open operation will fail andthis will in turn prevent ownership being taken (because a handle to thekey is required to change the key[ASCII 146]s security).
The solution to this problem is to first enable the TakeOwnership privilegeand then to open the registry key with WRITE_OWNER access as shown below: