正常的情况下如:
“dlgTest.exe”: 已卸载“F:\VCest\bin\BCGCBPRO1200ud90.dll”
“dlgTest.exe”: 已卸载“C:\Windows\SysWOW64\oleacc.dll”
“dlgTest.exe”: 已卸载“C:\Windows\SysWOW64\winmm.dll”
“dlgTest.exe”: 已卸载“C:\Windows\SysWOW64\odbc32.dll”
“dlgTest.exe”: 已卸载“C:\Windows\SysWOW64\comdlg32.dll”
“dlgTest.exe”: 已卸载“C:\Windows\SysWOW64\odbcint.dll”
现在的情况是:
Info: AfxDllCanUnloadNow returning S_OK
BCGCBPRO.DLL Terminating!
理论上 通过AfxDllCanUnloadNow 来卸载相关的dll
跟踪发现 在ocx的app中:
ExitInstance()函数 COleControlModule::ExitInstance()执行时会释放dll资源,
// terminate OLE last
_AFX_THREAD_STATE* pState = AfxGetThreadState();
// -1 is special case, so need to compare against TRUE
if (pState->m_bNeedTerm == TRUE)
{
CoFreeUnusedLibraries(); //这句执行异常(正常情况下会卸载所有dll资源), 直接跳回ExitInstance()函数重新执行
::OleUninitialize();
pState->m_bNeedTerm = FALSE;
}
不知道各位有没有人遇到过这种情况,或者相关的解决方法;
下边是封装后的ocx在对话框中的效果:
