source: trunk/src/oleacc/initterm.cpp@ 21976

Last change on this file since 21976 was 21976, checked in by dmik, 14 years ago

Fix some DLL init code that would return incorrect result on failure.

File size: 2.0 KB
Line 
1/* $Id: initterm.cpp,v 1.17 2001/09/05 10:26:30 bird Exp $
2 *
3 * OLEACC DLL entry point
4 *
5 * Copyright 1998 Sander van Leeuwen
6 * Copyright 1998 Peter Fitzsimmons
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 */
10
11#define INCL_DOSMODULEMGR
12#define INCL_DOSPROCESS
13#include <os2wrap.h> //Odin32 OS/2 api wrappers
14#include <stdlib.h>
15#include <stdio.h>
16#include <string.h>
17#include <odin.h>
18#include <win32api.h>
19#include <winconst.h>
20#include <odinlx.h>
21#include <cpuhlp.h>
22#include <dbglog.h>
23#include <initdll.h>
24
25// Win32 resource table (produced by wrc)
26extern DWORD oleacc_PEResTab;
27
28static HMODULE dllHandle = 0;
29
30BOOL WINAPI OleaccDllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved);
31
32static BOOL WINAPI OdinLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
33{
34 BOOL ret;
35
36 switch (fdwReason)
37 {
38 case DLL_PROCESS_ATTACH:
39 return OleaccDllMain(hinstDLL, fdwReason, fImpLoad);
40
41 case DLL_THREAD_ATTACH:
42 case DLL_THREAD_DETACH:
43 return OleaccDllMain(hinstDLL, fdwReason, fImpLoad);
44
45 case DLL_PROCESS_DETACH:
46 ret = OleaccDllMain(hinstDLL, fdwReason, fImpLoad);
47 return ret;
48 }
49 return FALSE;
50}
51
52ULONG SYSTEM DLL_InitOleAcc(ULONG hModule)
53{
54 if (!InitializeKernel32())
55 return -1;
56
57 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
58
59 dllHandle = RegisterLxDll(hModule, OdinLibMain, (PVOID)&oleacc_PEResTab);
60 if (dllHandle == 0)
61 return -1;
62
63 dprintf(("oleacc init %s %s (%x)", __DATE__, __TIME__, DLL_InitOleAcc));
64
65 return 0;
66}
67
68void SYSTEM DLL_TermOleAcc(ULONG hModule)
69{
70 if (dllHandle)
71 UnregisterLxDll(dllHandle);
72}
73
74ULONG SYSTEM DLL_Init(ULONG hModule)
75{
76 if (DLL_InitDefault(hModule) == -1)
77 return -1;
78 return DLL_InitOleAcc(hModule);
79}
80
81void SYSTEM DLL_Term(ULONG hModule)
82{
83 DLL_TermOleAcc(hModule);
84 DLL_TermDefault(hModule);
85}
Note: See TracBrowser for help on using the repository browser.