Microsoft KB Archive/167526

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 12:30, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base

Article ID: 167526

Article Last Modified on 10/24/2003


  • Microsoft ActiveX Template Library 2.0
  • Microsoft ActiveX Template Library 2.1
  • Microsoft ActiveX Template Library 3.0

This article was previously published under Q167526


An ATL control that superclasses a Windows control and runs on Windows NT can cause an access violation.


When ATL registers the Window Class for the control, it copies the WNDCLASSEX structure from the control it is superclassing. Because Windows controls are a global class, that attribute is given to the ATL control.

The problem occurs when the control[ASCII 146]s DLL is unloaded and then reloaded in the same process. ATL tries to register the Window Class with the current WndProcAddress, but Windows NT does not allow a Global Class to be overwritten. If the DLL was reloaded at another address, the next call to the WndProc causes an access violation.


In the file Atlwin.cpp, insert the following line (on line 610)) in the function CContainedWindow::RegisterWndSuperclass() just before the call to RegisterClassEx : &= ~CS_GLOBALCLASS;  // don't register as global class
   atom = ::RegisterClassEx(&wc);


Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Visual Studio 97 Service Pack 1.

For additional information about the Visual Studio 97 Service Pack 1, please see the following article in the Microsoft Knowledge Base:

170365 INFO: Visual Studio 97 Service Packs - What, Where, and Why


This bug is hard to reproduce because it will only appear if the client application unloads and then reloads the DLL and then the DLL is loaded at another address. But any superclassed control built without the above resolution may fail under the right conditions.

(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Chuck Bell, Microsoft Corporation

Additional query words: Control SuperClass Access Violation

Keywords: kbbug kbfix kbvs97sp1fix kbwndwclass kbctrlcreate KB167526