| Previous | Next |
| ERROR_CLASS_DOES_NOT_EXIST | ERROR_INVALID_INDEX |
ERROR_CLASS_HAS_WINDOWS
Live windows still use the class
UnregisterClass requires every window created with the specified class to be destroyed first. The window class is a template shared by its instances; removing the template while instances remain is prohibited.
Hidden windows, message-only windows, modeless dialogs, and windows created on secondary UI threads are common reasons an application believes cleanup is complete when a class still has instances. Destroying only the visible main window may therefore be insufficient.
What to check
- Enumerate or otherwise track every window instance created from the class.
- Shut down secondary GUI threads and message-only helper windows before class unregistration.
- Destroy modeless windows explicitly and wait for their owner threads to finish.
- Call
UnregisterClassonly after the instance count has reached zero.
This is different from ERROR_CLASS_ALREADY_EXISTS: the registration is valid, but teardown order prevents removing it.
References
Looking for a different code? Search another status or error code.