// // Common functions for Object DLL capabilities // C. Beaudet // #include "stdafx.h" #include "afxdllx.h" #include "ACP_Base.h" #include "ITF.h" #include "SNinterf.hpp" #include "x:\cpa\main\inc\_editid.h" //------------------------------------------------------------------------ // Global vars static char *gs_p_szCPAVersion = C_szCPAVersion; static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL }; #ifdef DLL_ONLY_ONE_INSTANCE static SNDEDIT_Interface g_oSNDEDITInterface; /* #else SNDEDIT_Interface* g_poSNDEDITInterface=NULL; */ #endif //------------------------------------------------------------------------ // functions that are present in all DLL : //------------------------------------------------------------------------ static CList g_oListOfInstances; //private internal //======================================================================== // Get current CPA version //======================================================================== /*extern "C"*/ char __declspec(dllexport) *fn_p_szGetCPAVersion(void) { return gs_p_szCPAVersion; } //======================================================================== // Get type of this DLL //======================================================================== extern "C" tdstDLLIdentity __declspec(dllexport) *fn_p_stGetDLLIdentity(void) { g_stSNDEDITIdentity . eType = TOOL_DLL; g_stSNDEDITIdentity . csName = C_szDLLSoundName; g_stSNDEDITIdentity . hModule = NULL; g_stSNDEDITIdentity . p_oListOfInstances = &g_oListOfInstances; return &g_stSNDEDITIdentity; } //======================================================================== // DLL int function //======================================================================== extern "C" void __declspec(dllexport) fn_vInitDll(void) { new CDynLinkLibrary(extensionDLL); } //======================================================================== // DLL entry point //======================================================================== extern "C" int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { if (dwReason == DLL_PROCESS_ATTACH) { // SND_hGlobalInst=hInstance; if (!AfxInitExtensionModule(extensionDLL, hInstance)) return 0; } return 1; } //======================================================================== // Get the DLL //======================================================================== extern "C" CPA_ToolDLLBase __declspec(dllexport) *fn_p_oGetDLL(long lKey) { #ifdef DLL_ONLY_ONE_INSTANCE switch(lKey) { case 0: // the game world if (g_poSNDEDITInterface == NULL) { g_poSNDEDITInterface = new SNDEDIT_Interface(); ASSERT(g_poSNDEDITInterface != NULL); } return g_poSNDEDITInterface; break; default: return NULL; } #else //DLL_ONLY_ONE_INSTANCE switch(lKey) { case 0: // the game world /* ASSERT(g_poSNDEDITInterface==NULL); g_poSNDEDITInterface=new SNDEDIT_Interface(); return g_poSNDEDITInterface; */ return new SNDEDIT_Interface(); break; default: return NULL; } #endif //DLL_ONLY_ONE_INSTANCE } //------------------------------------------------------------------------ // functions that are present in this type of DLL only : //------------------------------------------------------------------------ #undef DLL_ONLY_ONE_INSTANCE