KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q37355: Loadtime DLL Initialization for C 5.10

Article: Q37355
Product(s): See article
Version(s): 5.10   | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | softlib CRTDLL.ARC S12104.EXE | mspl13_c
Last Modified: 21-SEP-1989

Question:

How do I implement load-time DLL initialization without losing C
run-time support for my DLL?

Response:

Single-Threaded DLLs (that use LLIBCDLL.LIB)

There is an object module DLLINIT.OBJ that must be linked with your
routine. You must make an explicit call to C_INIT() to bring in
the C run-time startup code. If you are going to use DosLoadModule()
and DosFreeModule() to bring in and remove your DLL, then you must also
link in DLLTERM.OBJ. No explicit calls are necessary to use this
routine.

Multi-Threaded DLLs

There is an object module CRTDLL_I.OBJ that replaces the CRTDLL.OBJ
that comes with the C package. You should use CRTDLL_I.OBJ in the
exact same manner you would use CRTDLL.OBJ. You must also make a
reference to C_INIT() in your initialization routine. The prototype is
as follows:

   void far
   pascal C_INIT();.

All three object modules are in the Software Library archive file
CRTDLL.ARC. This file can be found in the Software Library by
searching on the filename CRTDLL.ARC, the Q number of this article, or
S12104.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.