#ifdef WINNT1/* dllinit.c -- Portable DLL initialization.2Copyright (C) 1998, 1999 Free Software Foundation, Inc.3Contributed by Mumit Khan ([email protected]).45I've used DllMain as the DLL "main" since that's the most common6usage. MSVC and Mingw32 both default to DllMain as the standard7callback from the linker entry point. Cygwin, as of b20.1, also8uses DllMain as the default callback from the entry point.910The real entry point is typically always defined by the runtime11library, and usually never overridden by (casual) user. What you can12override however is the callback routine that the entry point calls,13and this file provides such a callback function, DllMain.1415Mingw32: The default entry point for mingw32 is DllMainCRTStartup16which is defined in libmingw32.a This in turn calls DllMain which is17defined here. If not defined, there is a stub in libmingw32.a which18does nothing.1920Cygwin: The default entry point for Cygwin b20.1 or newer is21__cygwin_dll_entry which is defined in libcygwin.a. This in turn22calls the routine DllMain. If not defined, there is a stub in23libcygwin.a which does nothing.2425MSVC: MSVC runtime calls DllMain, just like Mingw32.2627Summary: If you need to do anything special in DllMain, just add it28here. Otherwise, the default setup should be just fine for 99%+ of29the time. I strongly suggest that you *not* change the entry point,30but rather change DllMain as appropriate.3132*/333435#define WIN32_LEAN_AND_MEAN36#include <windows.h>37#undef WIN32_LEAN_AND_MEAN38#include <stdio.h>3940BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason,41LPVOID reserved /* Not used. */ );4243/*44*----------------------------------------------------------------------45*46* DllMain --47*48* This routine is called by the Mingw32, Cygwin32 or VC++ C run49* time library init code, or the Borland DllEntryPoint routine. It50* is responsible for initializing various dynamically loaded51* libraries.52*53* Results:54* TRUE on sucess, FALSE on failure.55*56* Side effects:57*58*----------------------------------------------------------------------59*/60BOOL APIENTRY61DllMain (62HINSTANCE hInst /* Library instance handle. */ ,63DWORD reason /* Reason this function is being called. */ ,64LPVOID reserved /* Not used. */ )65{6667switch (reason)68{69case DLL_PROCESS_ATTACH:70break;7172case DLL_PROCESS_DETACH:73break;7475case DLL_THREAD_ATTACH:76break;7778case DLL_THREAD_DETACH:79break;80}81return TRUE;82}83#endif848586