| 1 | // $Id: dplayx_main.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ | 
|---|
| 2 | /* | 
|---|
| 3 | * DPLAYX.DLL LibMain | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 1999,2000 - Peter Hunnisett | 
|---|
| 6 | * | 
|---|
| 7 | * contact <hunnise@nortelnetworks.com> | 
|---|
| 8 | */ | 
|---|
| 9 | #include <string.h> | 
|---|
| 10 | #include <odin.h> | 
|---|
| 11 | #define ICOM_CINTERFACE 1 | 
|---|
| 12 | #define CINTERFACE | 
|---|
| 13 | #include "winerror.h" | 
|---|
| 14 | #include "winbase.h" | 
|---|
| 15 | #include "debugtools.h" | 
|---|
| 16 | #define INITGUID | 
|---|
| 17 | #include "initguid.h"  /* To define the GUIDs */ | 
|---|
| 18 | #include "dplaysp.h" | 
|---|
| 19 | #include "dplayx_global.h" | 
|---|
| 20 | #ifdef __WIN32OS2__ | 
|---|
| 21 | #include <initdll.h> | 
|---|
| 22 | #endif | 
|---|
| 23 |  | 
|---|
| 24 | DEFAULT_DEBUG_CHANNEL(dplay); | 
|---|
| 25 | DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | 
|---|
| 26 |  | 
|---|
| 27 | /* This is a globally exported variable at ordinal 6 of DPLAYX.DLL */ | 
|---|
| 28 | DWORD gdwDPlaySPRefCount = 0; /* FIXME: Should it be initialized here? */ | 
|---|
| 29 |  | 
|---|
| 30 | BOOL WINAPI DPLAYX_LibMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) | 
|---|
| 31 | { | 
|---|
| 32 |  | 
|---|
| 33 | TRACE( "(%u,0x%08lx,%p) & 0x%08lx\n", hinstDLL, fdwReason, lpvReserved, gdwDPlaySPRefCount ); | 
|---|
| 34 |  | 
|---|
| 35 | switch ( fdwReason ) | 
|---|
| 36 | { | 
|---|
| 37 | case DLL_PROCESS_ATTACH: | 
|---|
| 38 | /* First instance perform construction of global processor data */ | 
|---|
| 39 | return DPLAYX_ConstructData(); | 
|---|
| 40 |  | 
|---|
| 41 | case DLL_PROCESS_DETACH: | 
|---|
| 42 | { | 
|---|
| 43 | BOOL rc; | 
|---|
| 44 | /* Last instance performs destruction of global processor data */ | 
|---|
| 45 | rc = DPLAYX_DestructData(); | 
|---|
| 46 | #ifdef __WIN32OS2__ | 
|---|
| 47 | if(gdwDPlaySPRefCount==0) // only do this the last time ? | 
|---|
| 48 | ctordtorTerm(); | 
|---|
| 49 | #endif | 
|---|
| 50 | return rc; | 
|---|
| 51 |  | 
|---|
| 52 | break; | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | case DLL_THREAD_ATTACH: /* Do nothing */ | 
|---|
| 56 | case DLL_THREAD_DETACH: /* Do nothing */ | 
|---|
| 57 | break; | 
|---|
| 58 | default: | 
|---|
| 59 | break; | 
|---|
| 60 |  | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | return TRUE; | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | /*********************************************************************** | 
|---|
| 67 | *              DllCanUnloadNow (DPLAYX.10) | 
|---|
| 68 | */ | 
|---|
| 69 | HRESULT WINAPI DPLAYX_DllCanUnloadNow(void) | 
|---|
| 70 | { | 
|---|
| 71 | HRESULT hr = ( gdwDPlaySPRefCount > 0 ) ? S_FALSE : S_OK; | 
|---|
| 72 |  | 
|---|
| 73 | /* FIXME: Should I be putting a check in for class factory objects | 
|---|
| 74 | *        as well | 
|---|
| 75 | */ | 
|---|
| 76 |  | 
|---|
| 77 | TRACE( ": returning 0x%08lx\n", hr ); | 
|---|
| 78 |  | 
|---|
| 79 | return hr; | 
|---|
| 80 | } | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|