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

Last change on this file since 1378 was 1378, checked in by cbratschi, 26 years ago

Odin.ini color management support

File size: 5.1 KB
Line 
1/* $Id: initterm.cpp,v 1.12 1999-10-20 16:27:00 cbratschi 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#include "syscolor.h"
43
44/*-------------------------------------------------------------------*/
45/* A clean up routine registered with DosExitList must be used if */
46/* runtime calls are required and the runtime is dynamically linked. */
47/* This will guarantee that this clean up routine is run before the */
48/* library DLL is terminated. */
49/*-------------------------------------------------------------------*/
50static void APIENTRY cleanup(ULONG reason);
51static void APIENTRY cleanupQueue(ULONG ulReason);
52
53extern "C" {
54void CDECL _ctordtorInit( void );
55void CDECL _ctordtorTerm( void );
56}
57
58
59/****************************************************************************/
60/* _DLL_InitTerm is the function that gets called by the operating system */
61/* loader when it loads and frees this DLL for each process that accesses */
62/* this DLL. However, it only gets called the first time the DLL is loaded */
63/* and the last time it is freed for a particular process. The system */
64/* linkage convention MUST be used because the operating system loader is */
65/* calling this function. */
66/****************************************************************************/
67unsigned long SYSTEM _DLL_InitTerm(unsigned long hModule, unsigned long
68 ulFlag)
69{
70 size_t i;
71 APIRET rc;
72
73 /*-------------------------------------------------------------------------*/
74 /* If ulFlag is zero then the DLL is being loaded so initialization should */
75 /* be performed. If ulFlag is 1 then the DLL is being freed so */
76 /* termination should be performed. */
77 /*-------------------------------------------------------------------------*/
78
79 switch (ulFlag) {
80 case 0 :
81 _ctordtorInit();
82
83 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
84
85 if(RegisterLxDll(hModule, 0, 0) == FALSE)
86 return 0UL;
87
88 /*******************************************************************/
89 /* A DosExitList routine must be used to clean up if runtime calls */
90 /* are required and the runtime is dynamically linked. */
91 /*******************************************************************/
92
93 rc = DosExitList(0x0000F000|EXLST_ADD, cleanup);
94 if(rc)
95 return 0UL;
96
97 rc = DosExitList(0x00008000|EXLST_ADD, cleanupQueue);
98 if(rc)
99 return 0UL;
100
101 //SvL: Try to start communication with our message spy queue server
102 InitSpyQueue();
103
104 if(InitializeSharedHeap() == FALSE)
105 return 0UL;
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 //SvL: Create Desktop Window
117 if(CreateWin32Desktop() == FALSE) {
118 return 0UL;
119 }
120
121 break;
122 case 1 :
123 UnregisterLxDll(hModule);
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 cleanupQueue(ULONG ulReason)
136{
137 CloseSpyQueue();
138 DosExitList(EXLST_EXIT, cleanupQueue);
139}
140
141static void APIENTRY cleanup(ULONG ulReason)
142{
143 dprintf(("user32 exit\n"));
144 SYSCOLOR_Save();
145 DestroyDesktopWindow();
146 UnregisterSystemClasses();
147 DestroySharedHeap();
148 _ctordtorTerm();
149 dprintf(("user32 exit done\n"));
150 DosExitList(EXLST_EXIT, cleanup);
151 return ;
152}
Note: See TracBrowser for help on using the repository browser.