S
s3ven
Hello,
I'm programming with C++/ATL and i'm using the Vernoter sample. Testing
on Ol2003 with typelibe of OL2003
I'm experiencing random crashs of outlook when its closed : the crash
don't happen always it can takes some outlook restart to occur and when
i remove the call to DispEventUnadvise(m_pExplorer) in OnExplorerClose
(but leave the .Release and =NULL parts) the plugin stop crashing...
But sometimes (1/20) outlook remains in memory (i guess it's because no
Unadvise is called for the Explorer Events).
I want to add my Command Bar only to the main Explorer. How and where
should i free memory allocated to the Explorer's events?
(OnSelectionChange,Onbeforefolderswitch,OnExplorerClose)
Below are some parts of the code, thanks in advance for any
suggestions! I'm really stuck on this..
void _stdcall CApplication::OnExplorerClose(){
if (gPreviousFolder!=NULL)
{gPreviousFolder.Release();gPreviousFolder=NULL;}
if (idtimer!=NULL) {KillTimer(0,idtimer);}
if (idtimer_exp!=NULL) { KillTimer(0,idtimer_exp); }
if (m_pCallButton != NULL)
CommandButtonEvents:ispEventUnadvise(m_pCallButton);
if (m_pCallButton!=NULL)
{m_pCallButton.Release();m_pCallButton=NULL;}
if (m_pExplorer.p != NULL)
{
HRESULT hr=OutlookExpEvents:ispEventUnadvise(m_pExplorer);//is it ok
to call it here?
m_pExplorer.Release();m_pExplorer=NULL;
}
}
STDMETHODIMP CApplication::OnConnection(IDispatch *HostApp,
ext_ConnectMode ConnectMode, IDispatch *AddinInst, VARIANT *custom)
{
TCHAR szHomePath[_MAX_PATH] = {NULL};
TCHAR szDefaultSubject[MAX_SUBJECT_LENGHT] = {NULL};
DWORD dwCount =_MAX_PATH;
CRegKey RegKey;
CComBSTR bsKeyName, bsProjName;
long result = ~ERROR_SUCCESS;
vide.scode = DISP_E_PARAMNOTFOUND; vide.vt=VT_ERROR;
gpCApp = this;
idtimer=NULL; idtimer_exp=NULL;
m_pHostApp.Attach((Outlook::_Application *)HostApp);
gHostApp.Attach((Outlook::_Application *)HostApp);
m_pHostApp->GetNamespace(CComBSTR("MAPI"),&m_pNameSpace);
OutlookAppEvents:ispEventAdvise(m_pHostApp);
if (ConnectMode == ext_cm_AfterStartup)
{
OnStartupComplete(custom);
}
return S_OK;
}
STDMETHODIMP CApplication::OnDisconnection(ext_DisconnectMode
DisconnectMode, VARIANT *custom)
{
if (m_pNameSpace!=NULL)
{m_pNameSpace.Release();m_pNameSpace=NULL;}
if (gHostApp!=NULL) {gHostApp.Release();gHostApp=NULL;}
if (m_pHostApp.p != NULL)
{
HRESULT hr=OutlookAppEvents:ispEventUnadvise(m_pHostApp);
m_pHostApp.Release();
m_pHostApp=NULL;
}
}
STDMETHODIMP CApplication::OnStartupComplete(VARIANT *custom)
{
HRESULT hr = m_pHostApp->ActiveExplorer(&m_pExplorer);
if (SUCCEEDED(hr) && (m_pExplorer!=NULL)) {
OutlookExpEvents:ispEventAdvise(m_pExplorer);
} else
{
// if started with no explorer (minimized,mailto://,actives)
}
return S_OK;
}
I'm programming with C++/ATL and i'm using the Vernoter sample. Testing
on Ol2003 with typelibe of OL2003
I'm experiencing random crashs of outlook when its closed : the crash
don't happen always it can takes some outlook restart to occur and when
i remove the call to DispEventUnadvise(m_pExplorer) in OnExplorerClose
(but leave the .Release and =NULL parts) the plugin stop crashing...
But sometimes (1/20) outlook remains in memory (i guess it's because no
Unadvise is called for the Explorer Events).
I want to add my Command Bar only to the main Explorer. How and where
should i free memory allocated to the Explorer's events?
(OnSelectionChange,Onbeforefolderswitch,OnExplorerClose)
Below are some parts of the code, thanks in advance for any
suggestions! I'm really stuck on this..
void _stdcall CApplication::OnExplorerClose(){
if (gPreviousFolder!=NULL)
{gPreviousFolder.Release();gPreviousFolder=NULL;}
if (idtimer!=NULL) {KillTimer(0,idtimer);}
if (idtimer_exp!=NULL) { KillTimer(0,idtimer_exp); }
if (m_pCallButton != NULL)
CommandButtonEvents:ispEventUnadvise(m_pCallButton);
if (m_pCallButton!=NULL)
{m_pCallButton.Release();m_pCallButton=NULL;}
if (m_pExplorer.p != NULL)
{
HRESULT hr=OutlookExpEvents:ispEventUnadvise(m_pExplorer);//is it ok
to call it here?
m_pExplorer.Release();m_pExplorer=NULL;
}
}
STDMETHODIMP CApplication::OnConnection(IDispatch *HostApp,
ext_ConnectMode ConnectMode, IDispatch *AddinInst, VARIANT *custom)
{
TCHAR szHomePath[_MAX_PATH] = {NULL};
TCHAR szDefaultSubject[MAX_SUBJECT_LENGHT] = {NULL};
DWORD dwCount =_MAX_PATH;
CRegKey RegKey;
CComBSTR bsKeyName, bsProjName;
long result = ~ERROR_SUCCESS;
vide.scode = DISP_E_PARAMNOTFOUND; vide.vt=VT_ERROR;
gpCApp = this;
idtimer=NULL; idtimer_exp=NULL;
m_pHostApp.Attach((Outlook::_Application *)HostApp);
gHostApp.Attach((Outlook::_Application *)HostApp);
m_pHostApp->GetNamespace(CComBSTR("MAPI"),&m_pNameSpace);
OutlookAppEvents:ispEventAdvise(m_pHostApp);
if (ConnectMode == ext_cm_AfterStartup)
{
OnStartupComplete(custom);
}
return S_OK;
}
STDMETHODIMP CApplication::OnDisconnection(ext_DisconnectMode
DisconnectMode, VARIANT *custom)
{
if (m_pNameSpace!=NULL)
{m_pNameSpace.Release();m_pNameSpace=NULL;}
if (gHostApp!=NULL) {gHostApp.Release();gHostApp=NULL;}
if (m_pHostApp.p != NULL)
{
HRESULT hr=OutlookAppEvents:ispEventUnadvise(m_pHostApp);
m_pHostApp.Release();
m_pHostApp=NULL;
}
}
STDMETHODIMP CApplication::OnStartupComplete(VARIANT *custom)
{
HRESULT hr = m_pHostApp->ActiveExplorer(&m_pExplorer);
if (SUCCEEDED(hr) && (m_pExplorer!=NULL)) {
OutlookExpEvents:ispEventAdvise(m_pExplorer);
} else
{
// if started with no explorer (minimized,mailto://,actives)
}
return S_OK;
}