source: trunk/src/winmm/initterm.cpp@ 5135

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

VAC 3.6.5 bug workaround

File size: 4.6 KB
Line 
1/*
2 * WINMM DLL entry point
3 *
4 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
5 * Copyright 1998 Peter Fitzsimmons
6 * Copyright 2000 Chris Wohlgemuth
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13/*-------------------------------------------------------------*/
14/* INITERM.C -- Source for a custom dynamic link library */
15/* initialization and termination (_DLL_InitTerm) */
16/* function. */
17/* */
18/* When called to perform initialization, this sample function */
19/* gets storage for an array of integers, and initializes its */
20/* elements with random integers. At termination time, it */
21/* frees the array. Substitute your own special processing. */
22/*-------------------------------------------------------------*/
23
24
25/* Include files */
26#define INCL_DOSMODULEMGR
27#define INCL_DOSPROCESS
28#include <os2wrap.h> //Odin32 OS/2 api wrappers
29#include <stdlib.h>
30#include <stdio.h>
31#include <string.h>
32#include <builtin.h>
33#include <misc.h> /*PLF Wed 98-03-18 23:19:26*/
34#include <odin.h>
35#include <win32type.h>
36#include <winconst.h>
37#include <odinlx.h>
38#include <initdll.h>
39#include "auxiliary.h"
40
41#define DBG_LOCALLOG DBG_initterm
42#include "dbglocal.h"
43
44BOOL MULTIMEDIA_MciInit(void);
45BOOL MULTIMEDIA_CreateIData(HINSTANCE hinstDLL);
46void MULTIMEDIA_DeleteIData(void);
47
48extern "C" {
49void IRTMidiShutdown(); // IRTMidi shutdown routine
50
51 //Win32 resource table (produced by wrc)
52 extern DWORD _Resource_PEResTab;
53}
54static HMODULE dllHandle = 0;
55
56//******************************************************************************
57//******************************************************************************
58BOOL WINAPI LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
59{
60 static BOOL bInitDone = FALSE;
61
62 switch (fdwReason)
63 {
64 case DLL_PROCESS_ATTACH:
65 if (!MULTIMEDIA_CreateIData(hinstDLL))
66 return FALSE;
67
68 if (!bInitDone) { /* to be done only once */
69 if (!MULTIMEDIA_MciInit() /*|| !MMDRV_Init() */ ) {
70 MULTIMEDIA_DeleteIData();
71 return FALSE;
72 }
73 bInitDone = TRUE;
74 }
75
76 return TRUE;
77
78 case DLL_THREAD_ATTACH:
79 case DLL_THREAD_DETACH:
80 return TRUE;
81
82 case DLL_PROCESS_DETACH:
83 MULTIMEDIA_DeleteIData();
84 auxOS2Close(); /* SvL: Close aux device if necessary */
85 IRTMidiShutdown; /* JT: Shutdown RT Midi subsystem, if running. */
86 ctordtorTerm();
87 return TRUE;
88 }
89 return FALSE;
90}
91/****************************************************************************/
92/* _DLL_InitTerm is the function that gets called by the operating system */
93/* loader when it loads and frees this DLL for each process that accesses */
94/* this DLL. However, it only gets called the first time the DLL is loaded */
95/* and the last time it is freed for a particular process. The system */
96/* linkage convention MUST be used because the operating system loader is */
97/* calling this function. */
98/****************************************************************************/
99unsigned long _System _DLL_InitTerm(unsigned long hModule, unsigned long
100 ulFlag)
101{
102 size_t i;
103 APIRET rc;
104
105 /*-------------------------------------------------------------------------*/
106 /* If ulFlag is zero then the DLL is being loaded so initialization should */
107 /* be performed. If ulFlag is 1 then the DLL is being freed so */
108 /* termination should be performed. */
109 /*-------------------------------------------------------------------------*/
110
111 switch (ulFlag) {
112 case 0 :
113 ctordtorInit();
114
115 ParseLogStatus();
116
117 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
118
119 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
120 if(dllHandle == 0)
121 return 0UL;/* Error */
122
123 break;
124 case 1 :
125 auxOS2Close(); /* SvL: Close aux device if necessary */
126 if(dllHandle) {
127 UnregisterLxDll(dllHandle);
128 }
129 break;
130 default :
131 return 0UL;
132 }
133
134 /***********************************************************/
135 /* A non-zero value must be returned to indicate success. */
136 /***********************************************************/
137 return 1UL;
138}
139//******************************************************************************
140//******************************************************************************
141
142
143
Note: See TracBrowser for help on using the repository browser.