home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / dllmain.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  82 lines

  1. /***
  2. *dllmain.c - Dummy DllMain for user DLLs that have no notification handler
  3. *
  4. *       Copyright (c) 1993-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       This object goes into LIBC.LIB and LIBCMT.LIB and MSVCRT.LIB for use
  8. *       when linking a DLL with one of the three models of C run-time library.
  9. *       If the user does not provide a DllMain notification routine, this
  10. *       dummy handler will be linked in.  It always returns TRUE (success).
  11. *
  12. ******************************************************************************/
  13.  
  14. #ifdef _WIN32
  15.  
  16. #include <oscalls.h>
  17. #define _DECL_DLLMAIN   /* include prototype of _pRawDllMain */
  18. #include <process.h>
  19.  
  20. /***
  21. *DllMain - dummy version DLLs linked with all 3 C Run-Time Library models
  22. *
  23. *Purpose:
  24. *       The routine DllMain is always called by _DllMainCrtStartup.  If
  25. *       the user does not provide a routine named DllMain, this one will
  26. *       get linked in so that _DllMainCRTStartup has something to call.
  27. *
  28. *       For the LIBC.LIB and MSVCRT.LIB models, the CRTL does not need
  29. *       per-thread notifications so if the user is ignoring them (default
  30. *       DllMain and _pRawDllMain == NULL), just turn them off.  (WIN32-only)
  31. *
  32. *Entry:
  33. *
  34. *Exit:
  35. *
  36. *Exceptions:
  37. *
  38. ******************************************************************************/
  39.  
  40. BOOL WINAPI DllMain(
  41.         HANDLE  hDllHandle,
  42.         DWORD   dwReason,
  43.         LPVOID  lpreserved
  44.         )
  45. {
  46. #if !defined (_MT) || defined (CRTDLL)
  47.         if ( dwReason == DLL_PROCESS_ATTACH && ! _pRawDllMain )
  48.                 DisableThreadLibraryCalls(hDllHandle);
  49. #endif  /* !defined (_MT) || defined (CRTDLL) */
  50.         return TRUE ;
  51. }
  52.  
  53. #else  /* _WIN32 */
  54.  
  55. #include <cruntime.h>
  56. #include <macos\types.h>
  57. #include <macos\fragload.h>
  58.  
  59. /***
  60. *_DllInit - dummy version DLLs linked with all 2 C Run-Time Library models
  61. *
  62. *Purpose:
  63. *       The routine _DllInit is always called by _DllMainCrtStartup.  If
  64. *       the user does not provide a routine named _DllInit, this one will
  65. *       get linked in so that _DllMainCRTStartup has something to call.
  66. *
  67. *Entry:
  68. *
  69. *Exit:
  70. *
  71. *Exceptions:
  72. *
  73. ******************************************************************************/
  74.  
  75. OSErr _DllInit(InitBlockPtr pinitBlk)
  76. {
  77.         return noErr ;
  78. }
  79.  
  80.  
  81. #endif  /* _WIN32 */
  82.