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