1.2.3 Class Ownership

Windows determines class ownership from the hInstance member of the WNDCLASS structure passed to the RegisterClass function when the applica-tion or DLL registers the class. For Windows DLLs, the hInstance member must be the instance handle of the DLL. When the application that registered the class closes or the DLL that registered the class is unloaded, the class is destroyed. For this reason, all windows using the class must be destroyed before the application closes or the DLL is unloaded.