source: trunk/src/oleacc/initterm.cpp

Last change on this file 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
RevLine 
[21892]1/* $Id: initterm.cpp,v 1.17 2001/09/05 10:26:30 bird Exp $
[21313]2 *
[21892]3 * OLEACC DLL entry point
[21313]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
[21892]25// Win32 resource table (produced by wrc)
26extern DWORD oleacc_PEResTab;
[21313]27
28static HMODULE dllHandle = 0;
29
[21892]30BOOL WINAPI OleaccDllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved);
31
[21313]32static BOOL WINAPI OdinLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
33{
[21892]34 BOOL ret;
[21313]35
[21892]36 switch (fdwReason)
37 {
38 case DLL_PROCESS_ATTACH:
39 return OleaccDllMain(hinstDLL, fdwReason, fImpLoad);
[21313]40
[21892]41 case DLL_THREAD_ATTACH:
42 case DLL_THREAD_DETACH:
43 return OleaccDllMain(hinstDLL, fdwReason, fImpLoad);
[21313]44
[21892]45 case DLL_PROCESS_DETACH:
46 ret = OleaccDllMain(hinstDLL, fdwReason, fImpLoad);
47 return ret;
48 }
49 return FALSE;
[21313]50}
51
[21976]52ULONG SYSTEM DLL_InitOleAcc(ULONG hModule)
[21313]53{
[21892]54 if (!InitializeKernel32())
[21976]55 return -1;
[21313]56
[21892]57 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
[21313]58
[21892]59 dllHandle = RegisterLxDll(hModule, OdinLibMain, (PVOID)&oleacc_PEResTab);
60 if (dllHandle == 0)
61 return -1;
[21313]62
[21976]63 dprintf(("oleacc init %s %s (%x)", __DATE__, __TIME__, DLL_InitOleAcc));
[21649]64
[21892]65 return 0;
66}
[21313]67
[21976]68void SYSTEM DLL_TermOleAcc(ULONG hModule)
[21892]69{
70 if (dllHandle)
71 UnregisterLxDll(dllHandle);
72}
[21313]73
[21892]74ULONG SYSTEM DLL_Init(ULONG hModule)
75{
76 if (DLL_InitDefault(hModule) == -1)
77 return -1;
[21976]78 return DLL_InitOleAcc(hModule);
[21892]79}
[21313]80
[21892]81void SYSTEM DLL_Term(ULONG hModule)
82{
[21976]83 DLL_TermOleAcc(hModule);
[21892]84 DLL_TermDefault(hModule);
[21313]85}
Note: See TracBrowser for help on using the repository browser.