source: trunk/src/user32/initterm.cpp@ 6375

Last change on this file since 6375 was 6375, checked in by sandervl, 24 years ago

initterm update

File size: 4.3 KB
Line 
1/*
2 * USER32 DLL entry point
3 *
4 * Copyright 1998 Sander van Leeuwen
5 * Copyright 1998 Peter Fitzsimmons
6 *
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12/*-------------------------------------------------------------*/
13/* INITERM.C -- Source for a custom dynamic link library */
14/* initialization and termination (_DLL_InitTerm) */
15/* function. */
16/* */
17/* When called to perform initialization, this sample function */
18/* gets storage for an array of integers, and initializes its */
19/* elements with random integers. At termination time, it */
20/* frees the array. Substitute your own special processing. */
21/*-------------------------------------------------------------*/
22
23
24/* Include files */
25#define INCL_DOSMODULEMGR
26#define INCL_DOSPROCESS
27#define INCL_DOSSEMAPHORES
28#define INCL_DOSMISC
29#include <os2wrap.h> //Odin32 OS/2 api wrappers
30#include <stdlib.h>
31#include <stdio.h>
32#include <string.h>
33#include <odin.h>
34#include <misc.h> /*PLF Wed 98-03-18 23:18:29*/
35#include <win32type.h>
36#include <win32api.h>
37#include <winconst.h>
38#include <odinlx.h>
39#include "initterm.h"
40#include <exitlist.h>
41#include <initdll.h>
42
43#define DBG_LOCALLOG DBG_initterm
44#include "dbglocal.h"
45
46/*-------------------------------------------------------------------*/
47/* A clean up routine registered with DosExitList must be used if */
48/* runtime calls are required and the runtime is dynamically linked. */
49/* This will guarantee that this clean up routine is run before the */
50/* library DLL is terminated. */
51/*-------------------------------------------------------------------*/
52static void APIENTRY cleanup(ULONG reason);
53
54BOOL fVersionWarp3 = FALSE;
55
56/****************************************************************************/
57/* _DLL_InitTerm is the function that gets called by the operating system */
58/* loader when it loads and frees this DLL for each process that accesses */
59/* this DLL. However, it only gets called the first time the DLL is loaded */
60/* and the last time it is freed for a particular process. The system */
61/* linkage convention MUST be used because the operating system loader is */
62/* calling this function. */
63/****************************************************************************/
64ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG ulFlag)
65{
66 size_t i;
67 APIRET rc;
68 ULONG version[2];
69
70 /*-------------------------------------------------------------------------*/
71 /* If ulFlag is zero then the DLL is being loaded so initialization should */
72 /* be performed. If ulFlag is 1 then the DLL is being freed so */
73 /* termination should be performed. */
74 /*-------------------------------------------------------------------------*/
75
76 switch (ulFlag) {
77 case 0 :
78 ctordtorInit();
79 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
80
81 rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, version, sizeof(version));
82 if(rc == 0){
83 if(version[0] >= 20 && version[1] <= 30) {
84 fVersionWarp3 = TRUE;
85 }
86 }
87
88 /*******************************************************************/
89 /* A DosExitList routine must be used to clean up if runtime calls */
90 /* are required and the runtime is dynamically linked. */
91 /*******************************************************************/
92
93 rc = DosExitList(EXITLIST_USER32|EXLST_ADD, cleanup);
94 if(rc)
95 return 0UL;
96
97 rc = inittermUser32(hModule, ulFlag);
98 break;
99 case 1 :
100 rc = inittermUser32(hModule, ulFlag);
101 break;
102 default :
103 return 0UL;
104 }
105
106 /***********************************************************/
107 /* A non-zero value must be returned to indicate success. */
108 /***********************************************************/
109 return 1UL;
110}
111
112static void APIENTRY cleanup(ULONG ulReason)
113{
114 cleanupUser32(ulReason);
115 ctordtorTerm();
116
117 DosExitList(EXLST_EXIT, cleanup);
118}
119
Note: See TracBrowser for help on using the repository browser.