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

Last change on this file since 1376 was 1376, checked in by sandervl, 26 years ago

position change bugfixes

File size: 5.0 KB
Line 
1/* $Id: initterm.cpp,v 1.11 1999-10-20 13:46:25 sandervl Exp $ */
2
3/*
4 * USER32 DLL entry point
5 *
6 * Copyright 1998 Sander van Leeuwen
7 * Copyright 1998 Peter Fitzsimmons
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13
14/*-------------------------------------------------------------*/
15/* INITERM.C -- Source for a custom dynamic link library */
16/* initialization and termination (_DLL_InitTerm) */
17/* function. */
18/* */
19/* When called to perform initialization, this sample function */
20/* gets storage for an array of integers, and initializes its */
21/* elements with random integers. At termination time, it */
22/* frees the array. Substitute your own special processing. */
23/*-------------------------------------------------------------*/
24
25
26/* Include files */
27#define INCL_DOSMODULEMGR
28#define INCL_DOSPROCESS
29#define INCL_DOSSEMAPHORES
30#include <os2wrap.h> //Odin32 OS/2 api wrappers
31#include <stdlib.h>
32#include <stdio.h>
33#include <string.h>
34#include <odin.h>
35#include <misc.h> /*PLF Wed 98-03-18 23:18:29*/
36#include <win32type.h>
37#include <odinlx.h>
38#include <spy.h>
39#include "pmwindow.h"
40#include "heapshared.h"
41#include "win32wdesktop.h"
42
43/*-------------------------------------------------------------------*/
44/* A clean up routine registered with DosExitList must be used if */
45/* runtime calls are required and the runtime is dynamically linked. */
46/* This will guarantee that this clean up routine is run before the */
47/* library DLL is terminated. */
48/*-------------------------------------------------------------------*/
49static void APIENTRY cleanup(ULONG reason);
50static void APIENTRY cleanupQueue(ULONG ulReason);
51
52extern "C" {
53void CDECL _ctordtorInit( void );
54void CDECL _ctordtorTerm( void );
55}
56
57
58/****************************************************************************/
59/* _DLL_InitTerm is the function that gets called by the operating system */
60/* loader when it loads and frees this DLL for each process that accesses */
61/* this DLL. However, it only gets called the first time the DLL is loaded */
62/* and the last time it is freed for a particular process. The system */
63/* linkage convention MUST be used because the operating system loader is */
64/* calling this function. */
65/****************************************************************************/
66unsigned long SYSTEM _DLL_InitTerm(unsigned long hModule, unsigned long
67 ulFlag)
68{
69 size_t i;
70 APIRET rc;
71
72 /*-------------------------------------------------------------------------*/
73 /* If ulFlag is zero then the DLL is being loaded so initialization should */
74 /* be performed. If ulFlag is 1 then the DLL is being freed so */
75 /* termination should be performed. */
76 /*-------------------------------------------------------------------------*/
77
78 switch (ulFlag) {
79 case 0 :
80 _ctordtorInit();
81
82 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
83
84 if(RegisterLxDll(hModule, 0, 0) == FALSE)
85 return 0UL;
86
87 /*******************************************************************/
88 /* A DosExitList routine must be used to clean up if runtime calls */
89 /* are required and the runtime is dynamically linked. */
90 /*******************************************************************/
91
92 rc = DosExitList(0x0000F000|EXLST_ADD, cleanup);
93 if(rc)
94 return 0UL;
95
96 rc = DosExitList(0x00008000|EXLST_ADD, cleanupQueue);
97 if(rc)
98 return 0UL;
99
100 //SvL: Try to start communication with our message spy queue server
101 InitSpyQueue();
102
103 if(InitializeSharedHeap() == FALSE)
104 return 0UL;
105
106 //SvL: Init win32 PM classes
107 if(InitPM() == FALSE) {
108 return 0UL;
109 }
110
111 //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
112 //CB: register internal classes
113 RegisterSystemClasses(hModule);
114
115 //SvL: Create Desktop Window
116 if(CreateWin32Desktop() == FALSE) {
117 return 0UL;
118 }
119
120 break;
121 case 1 :
122 UnregisterLxDll(hModule);
123 break;
124 default :
125 return 0UL;
126 }
127
128 /***********************************************************/
129 /* A non-zero value must be returned to indicate success. */
130 /***********************************************************/
131 return 1UL;
132}
133
134static void APIENTRY cleanupQueue(ULONG ulReason)
135{
136 CloseSpyQueue();
137 DosExitList(EXLST_EXIT, cleanupQueue);
138}
139
140static void APIENTRY cleanup(ULONG ulReason)
141{
142 dprintf(("user32 exit\n"));
143 DestroyDesktopWindow();
144 UnregisterSystemClasses();
145 DestroySharedHeap();
146 _ctordtorTerm();
147 dprintf(("user32 exit done\n"));
148 DosExitList(EXLST_EXIT, cleanup);
149 return ;
150}
Note: See TracBrowser for help on using the repository browser.