source: trunk/src/opengl/glide/cvg/initterm.cpp

Last change on this file was 6653, checked in by bird, 24 years ago

Added $Id:$ keyword.

File size: 3.7 KB
Line 
1/* $Id: initterm.cpp,v 1.5 2001-09-05 14:30:18 bird Exp $ */
2/*
3 * DLL entry point
4 *
5 * Copyright 1998 Sander van Leeuwen
6 * Copyright 1998 Peter Fitzsimmons
7 *
8 *
9 */
10
11/*-------------------------------------------------------------*/
12/* INITERM.C -- Source for a custom dynamic link library */
13/* initialization and termination (_DLL_InitTerm) */
14/* function. */
15/* */
16/* When called to perform initialization, this sample function */
17/* gets storage for an array of integers, and initializes its */
18/* elements with random integers. At termination time, it */
19/* frees the array. Substitute your own special processing. */
20/*-------------------------------------------------------------*/
21
22
23/* Include files */
24#define INCL_DOSMODULEMGR
25#define INCL_DOSPROCESS
26#include <os2wrap.h> /* Odin32 OS/2 api wrappers */
27#include <stdlib.h>
28#include <stdio.h>
29#include <string.h>
30#include <odin.h>
31#include <win32type.h>
32#include <winconst.h>
33#include <odinlx.h>
34#include <misc.h> /* PLF Wed 98-03-18 23:18:15 */
35#include <initdll.h>
36
37extern "C" {
38 //Win32 resource table (produced by wrc)
39 extern DWORD _Resource_PEResTab;
40}
41static HMODULE dllHandle = 0;
42
43BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved);
44
45//******************************************************************************
46//******************************************************************************
47BOOL WINAPI LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
48{
49 switch (fdwReason)
50 {
51 case DLL_PROCESS_ATTACH:
52 case DLL_THREAD_ATTACH:
53 case DLL_THREAD_DETACH:
54 return DllMain(hinstDLL, fdwReason, fImpLoad);
55
56 case DLL_PROCESS_DETACH:
57 DllMain(hinstDLL, fdwReason, fImpLoad);
58 ctordtorTerm();
59 return TRUE;
60 }
61 return FALSE;
62}
63/****************************************************************************/
64/* _DLL_InitTerm is the function that gets called by the operating system */
65/* loader when it loads and frees this DLL for each process that accesses */
66/* this DLL. However, it only gets called the first time the DLL is loaded */
67/* and the last time it is freed for a particular process. The system */
68/* linkage convention MUST be used because the operating system loader is */
69/* calling this function. */
70/****************************************************************************/
71unsigned long SYSTEM _DLL_InitTerm(unsigned long hModule, unsigned long
72 ulFlag)
73{
74 size_t i;
75 APIRET rc;
76
77 /*-------------------------------------------------------------------------*/
78 /* If ulFlag is zero then the DLL is being loaded so initialization should */
79 /* be performed. If ulFlag is 1 then the DLL is being freed so */
80 /* termination should be performed. */
81 /*-------------------------------------------------------------------------*/
82
83 switch (ulFlag) {
84 case 0 :
85 ctordtorInit();
86
87 CheckVersionFromHMOD(PE2LX_VERSION, hModule);/* PLF Wed 98-03-18 05:28:48*/
88
89 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
90 if(dllHandle == 0)
91 return 0UL;
92
93 break;
94 case 1 :
95 if(dllHandle) {
96 UnregisterLxDll(dllHandle);
97 }
98 break;
99
100 default :
101 return 0UL;
102 }
103
104 /***********************************************************/
105 /* A non-zero value must be returned to indicate success. */
106 /***********************************************************/
107 return 1UL;
108}
Note: See TracBrowser for help on using the repository browser.