DLL Correctly Performs Initialization and TerminationLast reviewed: July 17, 1997Article ID: Q92731 |
7.00 7.00a | 1.00 1.50
MS-DOS | WINDOWSkbprg The information in this article applies to:
SUMMARYThe text below describes using Microsoft C/C++ version 7.0 to create a dynamic-link library (DLL) that correctly handles DLL initialization and termination. A DLL that uses these techniques calls the constructor for each global object when the DLL is loaded and the destructor for each global and static object when the DLL is freed. The DLL also correctly initializes the floating-support required by the C/C++ run-time libraries.
MORE INFORMATIONLIBENTRY.OBJ and WEP.OBJ are modules in the standard C run-time libraries for DLLs that contain the default DLL initialization and termination code, respectively. The DLL libraries are named xDLLCEW.LIB, where the letter x is replaced with a code to indicate the memory model. For example, SDLLCEW.LIB is the small memory model DLL library. Linking a DLL directly to it's own LIBENTRY.OBJ will over-ride any initialization done by the default LIBENTRY routine in the library. This initialization code is required to construct global objects and to load floating-point support. This situation can cause the following error message when an application implicitly loads DLLs:
Application Error Floating point support not loadedIf an application uses a DLL with its own WEP routine, the destructors for global and static objects are not called. To use the default LIBENTRY.OBJ file, link with the DLL library. To replace the LIBENTRY.OBJ file, list LIBENTRY.OBJ in the list of modules to link. To use the default WEP procedure, first make sure that none of the modules in the DLL contain a WEP procedure. Then add the following lines to the module definition (DEF) file for the DLL:
SEGMENTS 'WEP_TEXT' FIXED PRELOAD EXPORTS WEP @1 RESIDENTNAMEThe DETAILS.TXT file, distributed with Microsoft C/C++ version 7.0, describes this procedure in more detail. In Visual C++, refer to the "Programming Techniques" manual, chapters 6.3 and 6.4.
|
Additional reference words: kbinf 7.00 7.00a 1.00 1.50 start-up constant
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |