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

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

updates

File size: 4.9 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 _Resource_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
91 hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab,
92 USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
93 IMAGE_SUBSYSTEM_WINDOWS_GUI);
94 if(hInstanceUser32 == 0)
95 return 0UL;
96
97 dprintf(("user32 init %s %s (%x)", __DATE__, __TIME__, inittermUser32));
98
99 //SvL: Try to start communication with our message spy queue server
100 InitSpyQueue();
101
102 //SvL: Init win32 PM classes
103 if(InitPM() == FALSE) {
104 return 0UL;
105 }
106
107 //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
108 //CB: register internal classes
109 RegisterSystemClasses(hModule);
110
111 //CB: initialize PM monitor driver
112 MONITOR_Initialize(&MONITOR_PrimaryMonitor);
113
114 break;
115 case 1 :
116 if(hInstanceUser32) {
117 UnregisterLxDll(hInstanceUser32);
118 }
119 break;
120 default :
121 return 0UL;
122 }
123
124 /***********************************************************/
125 /* A non-zero value must be returned to indicate success. */
126 /***********************************************************/
127 return 1UL;
128}
129
130void APIENTRY cleanupUser32(ULONG ulReason)
131{
132 dprintf(("user32 exit\n"));
133//SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
134//// RestoreCursor();
135 DestroyDesktopWindow();
136 Win32BaseWindow::DestroyAll();
137 UnregisterSystemClasses();
138 Win32WndClass::DestroyAll();
139 MONITOR_Finalize(&MONITOR_PrimaryMonitor);
140 SYSCOLOR_Save();
141 CloseSpyQueue();
142 dprintf(("user32 exit done\n"));
143}
144
Note: See TracBrowser for help on using the repository browser.