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

Last change on this file since 5308 was 5307, checked in by sandervl, 25 years ago

BeginPaint error value fix + initterm update

File size: 5.2 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 <winconst.h>
36#include <odinlx.h>
37#include <spy.h>
38#include <monitor.h>
39#include "pmwindow.h"
40#include "win32wdesktop.h"
41#include "syscolor.h"
42#include "initterm.h"
43#include <exitlist.h>
44#include <initdll.h>
45
46#define DBG_LOCALLOG DBG_initterm
47#include "dbglocal.h"
48
49/*-------------------------------------------------------------------*/
50/* A clean up routine registered with DosExitList must be used if */
51/* runtime calls are required and the runtime is dynamically linked. */
52/* This will guarantee that this clean up routine is run before the */
53/* library DLL is terminated. */
54/*-------------------------------------------------------------------*/
55static void APIENTRY cleanup(ULONG reason);
56
57extern "C" {
58 //Win32 resource table (produced by wrc)
59 extern DWORD _Resource_PEResTab;
60}
61DWORD hInstanceUser32 = 0;
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/****************************************************************************/
71ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG ulFlag)
72{
73 size_t i;
74 APIRET rc;
75
76 /*-------------------------------------------------------------------------*/
77 /* If ulFlag is zero then the DLL is being loaded so initialization should */
78 /* be performed. If ulFlag is 1 then the DLL is being freed so */
79 /* termination should be performed. */
80 /*-------------------------------------------------------------------------*/
81
82 switch (ulFlag) {
83 case 0 :
84 ctordtorInit();
85 ParseLogStatus();
86
87 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
88
89 hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab,
90 USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
91 IMAGE_SUBSYSTEM_WINDOWS_GUI);
92 if(hInstanceUser32 == 0)
93 return 0UL;
94
95 /*******************************************************************/
96 /* A DosExitList routine must be used to clean up if runtime calls */
97 /* are required and the runtime is dynamically linked. */
98 /*******************************************************************/
99
100 rc = DosExitList(EXITLIST_USER32|EXLST_ADD, cleanup);
101 if(rc)
102 return 0UL;
103
104 //SvL: Try to start communication with our message spy queue server
105 InitSpyQueue();
106
107 //SvL: Init win32 PM classes
108 if(InitPM() == FALSE) {
109 return 0UL;
110 }
111
112 //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
113 //CB: register internal classes
114 RegisterSystemClasses(hModule);
115
116 //CB: initialize PM monitor driver
117 MONITOR_Initialize(&MONITOR_PrimaryMonitor);
118
119 break;
120 case 1 :
121 if(hInstanceUser32) {
122 UnregisterLxDll(hInstanceUser32);
123 }
124 break;
125 default :
126 return 0UL;
127 }
128
129 /***********************************************************/
130 /* A non-zero value must be returned to indicate success. */
131 /***********************************************************/
132 return 1UL;
133}
134
135static void APIENTRY cleanup(ULONG ulReason)
136{
137 dprintf(("user32 exit\n"));
138 DestroyDesktopWindow();
139 Win32BaseWindow::DestroyAll();
140 UnregisterSystemClasses();
141 Win32WndClass::DestroyAll();
142 MONITOR_Finalize(&MONITOR_PrimaryMonitor);
143 SYSCOLOR_Save();
144 CloseSpyQueue();
145 ctordtorTerm();
146 dprintf(("user32 exit done\n"));
147
148 DosExitList(EXLST_EXIT, cleanup);
149}
150
Note: See TracBrowser for help on using the repository browser.