source: trunk/src/user32/inituser32.cpp@ 6496

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

init changes

File size: 5.0 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 <spy.h>
40#include <monitor.h>
41#include "pmwindow.h"
42#include "win32wdesktop.h"
43#include "syscolor.h"
44#include "initterm.h"
45#include <exitlist.h>
46#include <initdll.h>
47
48#define DBG_LOCALLOG DBG_initterm
49#include "dbglocal.h"
50
51/*-------------------------------------------------------------------*/
52/* A clean up routine registered with DosExitList must be used if */
53/* runtime calls are required and the runtime is dynamically linked. */
54/* This will guarantee that this clean up routine is run before the */
55/* library DLL is terminated. */
56/*-------------------------------------------------------------------*/
57static void APIENTRY cleanup(ULONG reason);
58
59extern "C" {
60 //Win32 resource table (produced by wrc)
61 extern DWORD user32_PEResTab;
62}
63DWORD hInstanceUser32 = 0;
64
65/****************************************************************************/
66/* _DLL_InitTerm is the function that gets called by the operating system */
67/* loader when it loads and frees this DLL for each process that accesses */
68/* this DLL. However, it only gets called the first time the DLL is loaded */
69/* and the last time it is freed for a particular process. The system */
70/* linkage convention MUST be used because the operating system loader is */
71/* calling this function. */
72/****************************************************************************/
73ULONG APIENTRY inittermUser32(ULONG hModule, ULONG ulFlag)
74{
75 size_t i;
76 APIRET rc;
77 ULONG version[2];
78
79 /*-------------------------------------------------------------------------*/
80 /* If ulFlag is zero then the DLL is being loaded so initialization should */
81 /* be performed. If ulFlag is 1 then the DLL is being freed so */
82 /* termination should be performed. */
83 /*-------------------------------------------------------------------------*/
84
85 switch (ulFlag) {
86 case 0 :
87 ParseLogStatusUSER32();
88
89 InitializeKernel32();
90 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
91
92 hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&user32_PEResTab,
93 USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
94 IMAGE_SUBSYSTEM_WINDOWS_GUI);
95 if(hInstanceUser32 == 0)
96 return 0UL;
97
98 dprintf(("user32 init %s %s (%x)", __DATE__, __TIME__, inittermUser32));
99
100 //SvL: Try to start communication with our message spy queue server
101 InitSpyQueue();
102
103 //SvL: Init win32 PM classes
104 if(InitPM() == FALSE) {
105 return 0UL;
106 }
107
108 //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
109 //CB: register internal classes
110 RegisterSystemClasses(hModule);
111
112 //CB: initialize PM monitor driver
113 MONITOR_Initialize(&MONITOR_PrimaryMonitor);
114
115 break;
116 case 1 :
117 if(hInstanceUser32) {
118 UnregisterLxDll(hInstanceUser32);
119 }
120 break;
121 default :
122 return 0UL;
123 }
124
125 /***********************************************************/
126 /* A non-zero value must be returned to indicate success. */
127 /***********************************************************/
128 return 1UL;
129}
130
131void APIENTRY cleanupUser32(ULONG ulReason)
132{
133 dprintf(("user32 exit\n"));
134//SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
135//// RestoreCursor();
136 DestroyDesktopWindow();
137 Win32BaseWindow::DestroyAll();
138 UnregisterSystemClasses();
139 Win32WndClass::DestroyAll();
140 MONITOR_Finalize(&MONITOR_PrimaryMonitor);
141 SYSCOLOR_Save();
142 CloseSpyQueue();
143 dprintf(("user32 exit done\n"));
144}
145
Note: See TracBrowser for help on using the repository browser.