Article ID: 111546 - Last Review: November 21, 2006 - Revision: 4.1 INFO: Taking Ownership of Registry KeysThis article was previously published under Q111546 SUMMARY
To take ownership of a registry key it is necessary to have a handle to the
key. A handle to the key can be obtained by opening the key with a registry
API (application programming interface) such as RegOpenKeyEx(). If the user
does not have access to the registry key, the open operation will fail and
this will in turn prevent ownership being taken (because a handle to the
key is required to change the key[ASCII 146]s security).
The solution to this problem is to first enable the TakeOwnership privilege and then to open the registry key with WRITE_OWNER access as shown below: RegOpenKeyEx(HKEY_CLASSES_ROOT,"Testkey",0,WRITE_OWNER,&hKey); RegSetKeySecurity(hKey,OWNER_SECURITY_INFORMATION, &SecurityDescriptor); Taking ownership of a registry key is not a common operation. It is typically an operation that an administrator would use as a last resort to gain access to a registry key. APPLIES TO
| Article Translations
|
Back to the top
