0
我正在開發用於VC6和VC9的VC加載項。以下代碼來自我的作品。在CViaDevStudio::Evaluate
之後,我打電話給pDebugger->Release()
,一切正常。但在CViaVisualStudio::ReadFromMemory
中,在我撥打pDebugger->Release()
或pProc->Release()
後,VC9會提示錯誤提示錯誤號碼未指定。我不知道爲什麼。我認爲在使用COM對象後調用Release()
是合理的。爲什麼我不能調用發佈COM對象的接口
/* VC6 */
class CViaDevStudio {
...
IApplication* m_pApplication;
};
BOOL CViaDevStudio::Evaluate(char* szExp, TCHAR* value, int size)
{
BOOL re = FALSE;
IDebugger* pDebugger = NULL;
m_pApplication->get_Debugger((IDispatch**)&pDebugger);
if (pDebugger) {
...
}
exit:
// The following code must be called, otherwise VC6 will complaint invalid access
// when it's started again
if (pDebugger)
pDebugger->Release();
return re;
}
/* VC9 */
class CViaVisualStudio {
...
CComPtr<EnvDTE::_DTE> m_pApplication;
};
BOOL CViaVisualStudio::ReadFromMemory(PBYTE pDst, PBYTE pSrc, long size)
{
BOOL re = FALSE;
EnvDTE::DebuggerPtr pDebugger;
EnvDTE::ProcessPtr pProc;
if (S_OK == m_pApplication->get_Debugger(&pDebugger)) {
if (S_OK == pDebugger->get_CurrentProcess(&pProc)) {
...
}
}
}
exit:
// I don't know why the following enclosed with macros should not be called.
#if 0
if (pDebugger)
pDebugger->Release();
if (pProc)
pProc->Release();
#endif
return re;
}
非常感謝! – 2010-10-08 02:17:59