| Previous | Next |
| ERROR_FATAL_APP_EXIT | ERROR_WAS_UNLOCKED |
ERROR_PREDEFINED_HANDLE
A registry operation encountered a predefined key handle
ERROR_PREDEFINED_HANDLE corresponds to Win32 error value documented as: The specified registry key is referenced by a predefined handle. Windows uses special handles for roots such as HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER. This result warns that code is treating one of those predefined handles as though it were an ordinary handle returned by RegOpenKeyEx.
Where the result appears in real systems
- Registry wrappers that close every received HKEY unconditionally.
- Ownership-transfer code that cannot distinguish borrowed root handles from opened subkeys.
- Cleanup logic shared between predefined roots and dynamically opened keys.
What to collect before making changes
Record the numeric HKEY value and the API being called; trace where ownership of the handle was assigned; verify whether the failing path begins with HKLM, HKCU, HKCR, HKU, or HKCC; enable Application Verifier handle checks for a reproducible case.
Handling and recovery
Represent predefined roots as non-owning handles. Only close handles actually returned by an open or create operation, and make wrapper ownership explicit in its type or constructor.
What not to infer from this code
This result is not a permissions error and changing ACLs will not fix it. It identifies incorrect handle lifetime or API usage around a registry root.
References
Looking for a different code? Search another status or error code.