Esempio n. 1
0
BOOL PASCAL COleObjectFactory::RegisterAll()
{
	BOOL bResult = TRUE;
	// register application factories
	AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
	AfxLockGlobals(CRIT_OBJECTFACTORYLIST);
	for (COleObjectFactory* pFactory = pModuleState->m_factoryList;
		pFactory != NULL; pFactory = pFactory->m_pNextFactory)
	{
		// register any non-registered, non-doctemplate factories
		if (!pFactory->IsRegistered() &&
			pFactory->m_clsid != CLSID_NULL && !pFactory->Register())
		{
			bResult = FALSE;
		}
	}
	AfxUnlockGlobals(CRIT_OBJECTFACTORYLIST);
#ifdef _AFXDLL
	// register extension DLL factories
	AfxLockGlobals(CRIT_DYNLINKLIST);
	for (CDynLinkLibrary* pDLL = pModuleState->m_libraryList; pDLL != NULL;
		pDLL = pDLL->m_pNextDLL)
	{
		for (pFactory = pDLL->m_factoryList;
			pFactory != NULL; pFactory = pFactory->m_pNextFactory)
		{
			// register any non-registered, non-doctemplate factories
			if (!pFactory->IsRegistered() &&
				pFactory->m_clsid != CLSID_NULL && !pFactory->Register())
			{
				bResult = FALSE;
			}
		}
	}
	AfxUnlockGlobals(CRIT_DYNLINKLIST);
#endif
	return bResult;
}
Esempio n. 2
0
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		TRACE0("FILLMODE.VMD Initializing!\n");
		
	bool bRegister = !FillModeDLL.bInitialized;

		GetModuleFileName (hInstance, g_pDLLName, _MAX_PATH);
		g_hInstance = hInstance;
#if !defined(_NOVERSION)
		PreCalcVersion();
#endif // !defined(_NOVERSION)

	// Extension DLL one-time initialization
		if (!AfxInitExtensionModule(FillModeDLL, hInstance)) {
			TRACE1("Could not init ExtensionModule %s\r\n", g_pDLLName);
			return false;   // failure
		}

	// Insert this DLL into the resource chain
	CDynLinkLibrary *pDLL = new CDynLinkLibrary(FillModeDLL);
		
		if (pDLL == NULL) {
			TRACE1("Out of memory in DLLInit of %s\r\n", g_pDLLName);
			return false;   // failure
		}
		pDLL -> m_bSystem = true;
			
	// externe Funktionen von Trias abfragen
#if defined(__XT) && defined(__DEXPROCS)
	HMODULE hTrias = GetModuleHandle (NULL);

		g_pDexExtensionProc = (DEXEXTENSIONPROC)GetProcAddress (hTrias, "DEXEXTENSIONPROC");
#endif // __XT && __DEXPROCS
#if _MSC_VER >= 1000
		{
		// Register class factories in context of private module state
		bool bResult = true;

			if (bRegister) {
			// register this DLL's factories
				AfxLockGlobals(CRIT_OBJECTFACTORYLIST);
				for (COleObjectFactory *pFactory = pDLL->m_factoryList;
					 pFactory != NULL; pFactory = pFactory->m_pNextFactory)
				{
					// register any non-registered, non-doctemplate factories
					if (!pFactory->IsRegistered() &&
						pFactory->GetClassID() != CLSID_NULL && !pFactory->Register())
					{
						TRACE1("Could not init classFactory in %s\r\n", g_pDLLName);
						bResult = false;
					}
				}
				AfxUnlockGlobals(CRIT_OBJECTFACTORYLIST);
			}
			if (!bResult) return false;
		}
#endif //_MSC_VER
	}
	else if (dwReason == DLL_PROCESS_DETACH)
	{
		TRACE0("FILLMODE.VMD Terminating!\n");
		AfxTermExtensionModule(FillModeDLL);
	}
	return 1;   // ok
}