Microsoft KB Archive/214784

{|
 * width="100%"|

PRB: FreeLibrary Fails When Called Within DLL_PROCESS_DETACH Code

 * }

Q214784

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * Microsoft Windows 98

-

SYMPTOMS
In Windows 98, FreeLibrary will return FALSE if it is called within the DLL_PROCESS_DETACH code of DllMain.

CAUSE
Never call LoadLibrary or FreeLibrary within DllMain. These calls can create dependency loops and result in thread deadlock. This has always been the case and is made clear within the Warning section in the online documentation for DllMain.

In Windows 95, the operating system made no attempt to enforce this DLL serialization rule. Hence, an unsafe call to FreeLibrary within DllMain would return TRUE. Windows 98 returns FALSE for such a call in order to more strictly enforce this rule. This may cause problems for pre-existing code that did not heed the warning.

STATUS
This behavior is by design.

Additional query words:

Keywords : kbDLL kbKernBase

Issue type : kbprb

Technology : kbAudDeveloper kbWin32sSearch kbWin32API