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

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

enable mouse cursor in user32 exitlist

File size: 5.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#include <os2wrap.h> //Odin32 OS/2 api wrappers
29#include <stdlib.h>
30#include <stdio.h>
31#include <string.h>
32#include <odin.h>
33#include <misc.h> /*PLF Wed 98-03-18 23:18:29*/
34#include <win32type.h>
35#include <win32api.h>
36#include <winconst.h>
37#include <odinlx.h>
38#include <spy.h>
39#include <monitor.h>
40#include "pmwindow.h"
41#include "win32wdesktop.h"
42#include "syscolor.h"
43#include "initterm.h"
44#include <exitlist.h>
45#include <initdll.h>
46
47#define DBG_LOCALLOG DBG_initterm
48#include "dbglocal.h"
49
50/*-------------------------------------------------------------------*/
51/* A clean up routine registered with DosExitList must be used if */
52/* runtime calls are required and the runtime is dynamically linked. */
53/* This will guarantee that this clean up routine is run before the */
54/* library DLL is terminated. */
55/*-------------------------------------------------------------------*/
56static void APIENTRY cleanup(ULONG reason);
57
58extern "C" {
59 //Win32 resource table (produced by wrc)
60 extern DWORD _Resource_PEResTab;
61}
62DWORD hInstanceUser32 = 0;
63
64/****************************************************************************/
65/* _DLL_InitTerm is the function that gets called by the operating system */
66/* loader when it loads and frees this DLL for each process that accesses */
67/* this DLL. However, it only gets called the first time the DLL is loaded */
68/* and the last time it is freed for a particular process. The system */
69/* linkage convention MUST be used because the operating system loader is */
70/* calling this function. */
71/****************************************************************************/
72ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG 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 ParseLogStatus();
87
88 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
89
90 hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab,
91 USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
92 IMAGE_SUBSYSTEM_WINDOWS_GUI);
93 if(hInstanceUser32 == 0)
94 return 0UL;
95
96 dprintf(("user32 init %s %s (%x)", __DATE__, __TIME__, DLLENTRYPOINT_NAME));
97
98 /*******************************************************************/
99 /* A DosExitList routine must be used to clean up if runtime calls */
100 /* are required and the runtime is dynamically linked. */
101 /*******************************************************************/
102
103 rc = DosExitList(EXITLIST_USER32|EXLST_ADD, cleanup);
104 if(rc)
105 return 0UL;
106
107 //SvL: Try to start communication with our message spy queue server
108 InitSpyQueue();
109
110 //SvL: Init win32 PM classes
111 if(InitPM() == FALSE) {
112 return 0UL;
113 }
114
115 //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
116 //CB: register internal classes
117 RegisterSystemClasses(hModule);
118
119 //CB: initialize PM monitor driver
120 MONITOR_Initialize(&MONITOR_PrimaryMonitor);
121
122 break;
123 case 1 :
124 if(hInstanceUser32) {
125 UnregisterLxDll(hInstanceUser32);
126 }
127 break;
128 default :
129 return 0UL;
130 }
131
132 /***********************************************************/
133 /* A non-zero value must be returned to indicate success. */
134 /***********************************************************/
135 return 1UL;
136}
137
138static void APIENTRY cleanup(ULONG ulReason)
139{
140 dprintf(("user32 exit\n"));
141 ShowCursor(TRUE);
142 DestroyDesktopWindow();
143 Win32BaseWindow::DestroyAll();
144 UnregisterSystemClasses();
145 Win32WndClass::DestroyAll();
146 MONITOR_Finalize(&MONITOR_PrimaryMonitor);
147 SYSCOLOR_Save();
148 CloseSpyQueue();
149 ctordtorTerm();
150 dprintf(("user32 exit done\n"));
151
152 DosExitList(EXLST_EXIT, cleanup);
153}
154
Note: See TracBrowser for help on using the repository browser.