home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0210 - 0219 / ibm0210-0219 / ibm0213.tar / ibm0213 / 7025PWA1.ZIP / SAMPLES.ZIP / SQLLIB / SAMPLES / C / LIBMAIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-28  |  2.0 KB  |  54 lines

  1. #include "windows.h"
  2.  
  3. /****************************************************************************/
  4. /****************************************************************************
  5.    FUNCTION: LibMain(HANDLE, WORD, WORD, LPSTR)
  6.  
  7.    PURPOSE:  Is called by LibEntry.  LibEntry is called by Windows when
  8.              the DLL is loaded.  The LibEntry routine is provided in
  9.              the LIBENTRY.OBJ in the SDK Link Libraries disk.  (The
  10.              source LIBENTRY.ASM is also provided.)
  11.  
  12.              LibEntry initializes the DLL's heap, if a HEAPSIZE value is
  13.              specified in the DLL's DEF file.  Then LibEntry calls
  14.              LibMain.  The LibMain function below satisfies that call.
  15.  
  16.              The LibMain function should perform additional initialization
  17.              tasks required by the DLL.  In this example, no initialization
  18.              tasks are required.  LibMain should return a value of 1 if
  19.              the initialization is successful.
  20.  
  21. *******************************************************************************/
  22.  
  23. int FAR PASCAL LibMain(hModule, wDataSeg, wHeapSize, lpszCmdLine)
  24. HANDLE  hModule;
  25. WORD    wDataSeg;
  26. WORD    wHeapSize;
  27. LPSTR   lpszCmdLine;
  28. {
  29.   int rc ;
  30.  
  31.   if (wHeapSize == 0)
  32.     return 0 ;
  33.  
  34.   rc = LocalInit( wDataSeg, NULL, (WORD) wHeapSize ) ;
  35.   return rc;
  36. }
  37.  
  38. /****************************************************************************
  39.     FUNCTION:  WEP(int)
  40.  
  41.     PURPOSE:  Performs cleanup tasks when the DLL is unloaded.  WEP() is
  42.               called automatically by Windows when the DLL is unloaded (no
  43.               remaining tasks still have the DLL loaded).  It is strongly
  44.               recommended that a DLL have a WEP() function, even if it does
  45.               nothing but returns success (1), as in this example.
  46.  
  47. *******************************************************************************/
  48. int FAR PASCAL WEP (bSystemExit)
  49. int  bSystemExit;
  50. {
  51.     return(1);
  52. }
  53.  
  54.