Example #1
0
void AFXAPI AfxOleUnlockApp() {
	AfxGetModuleState()->m_comModule.Unlock();
	AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
	if (AfxOleCanExitApp()) {
		AfxOleOnReleaseAllObjects();
	}
}
Example #2
0
HRESULT AFXAPI AfxDllCanUnloadNow() {
	try {
		return AfxOleCanExitApp() ? S_OK : S_FALSE;
	} catch (RCExc ex) {
		return HResultInCatch(ex);
	}
}
Example #3
0
SCODE AFXAPI AfxDllCanUnloadNow(void)
{
    // return S_OK only if no outstanding objects active
    if (AfxOleCanExitApp())
    {
        TRACE0("Info: AfxDllCanUnloadNow returning S_OK\n");
        return S_OK;
    }
    return S_FALSE;
}
Example #4
0
void CMainFrame::OnClose()
{
	if( GetApp()->ComparisonRunning() )
		return;

	CChildFrame* const pFrame = DYNAMIC_DOWNCAST( CChildFrame, MDIGetActive() );

	if (CloseAll(0))
	{
		CMDIFrameWndEx::OnClose();

		// bombs away! - unlock the app from ole automation references - be like word.application and go away when UI is closed
		while (!AfxOleCanExitApp())
			AfxOleUnlockApp();
	}
}
Example #5
0
SCODE AFXAPI AfxDllCanUnloadNow(void)
{
	// return S_OK only if no outstanding objects active
	if (!AfxOleCanExitApp())
		return S_FALSE;

	// check if any class factories with >1 reference count
	AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
	AfxLockGlobals(CRIT_OBJECTFACTORYLIST);
	COleObjectFactory* pFactory;
	for (pFactory = pModuleState->m_factoryList;
		pFactory != NULL; pFactory = pFactory->m_pNextFactory)
	{
		if (pFactory->m_dwRef > 1)
		{
			AfxUnlockGlobals(CRIT_OBJECTFACTORYLIST);
			return S_FALSE;
		}
	}
	AfxUnlockGlobals(CRIT_OBJECTFACTORYLIST);
#ifdef _AFXDLL
	AfxLockGlobals(CRIT_DYNLINKLIST);
	// search factories defined in extension DLLs
	for (CDynLinkLibrary* pDLL = pModuleState->m_libraryList; pDLL != NULL;
		pDLL = pDLL->m_pNextDLL)
	{
		for (COleObjectFactory* pDLLFactory = pDLL->m_factoryList;
			pDLLFactory != NULL; pDLLFactory = pDLLFactory->m_pNextFactory)
		{
			if (pDLLFactory->m_dwRef > 1)
			{
				AfxUnlockGlobals(CRIT_DYNLINKLIST);
				return S_FALSE;
			}
		}
	}
	AfxUnlockGlobals(CRIT_DYNLINKLIST);
#endif

	TRACE(traceOle, 0, "Info: AfxDllCanUnloadNow returning S_OK\n");
	return S_OK;
}