VC++ - Importent Outlook - Add in close

I was just working with Outlook 7 and made aVC++- ATL addin and things were very fine. for a moment i just shifted my code on Outlook 2003 the things gone changed ...suddenly my smile converted in deep worry becoz of in case of multiple instance i was not able to close all the explorer of outlook.outlook was not getting closed,was running behind. then after a lots of debug loops i found where exactly the problem........
here i am goin to list some issues that may be a part of such problems while developin a com addin for outlook.
1 - if u are registering any event (DispEventAdvise(.......)) with button or menu item just check that its having corresponding un registeration(DispEventUnadvise(...........)).If DispEventAdvise is coming in your code then there must be DispEventUnadvise(.....).
2 - Arelease the explorer object that u r using.
3 - free all the Com object that u r using.
4 - always try to handle the events that you are using in your addin case in a different class.

Here i am giving example code as my .ccp file where i am handling my new explorer event....
#include "StdAfx.h"
#include "ExplorerEventSink.h"
#include "atlcom.h"
typedef IDispEventSimpleImpl< href="outlook::ExplorerEvents_10"> Outlook::ExplorerEvents_10 )> ExplorerCloseEvent;_ATL_FUNC_INFO ExplorerQuitInfo = {CC_STDCALL,VT_EMPTY};
CExplorerEventSink::CExplorerEventSink() { mRefCount = 1;}CExplorerEventSink::~CExplorerEventSink(){ Uninitialize(); }
HRESULT CExplorerEventSink::Initialize(CComPtr<Outlook::_Explorer> explorer){ HRESULT hResult = S_OK; i
f( FAILED( hResult = ExplorerCloseEvent::DispEventAdvise( explorer)))
return hResult;
m_Explorer = explorer; return S_OK;}
void CExplorerEventSink::Uninitialize()
{ if( m_Explorer) { ExplorerCloseEvent::DispEventUnadvise( m_Explorer);
m_Explorer->Release();
m_Explorer = NULL; }}
void __stdcall CExplorerEventSink::OnExplorerClose(){ delete this;}
............
write me if any spacific issue u are facing...
we will try to handle together :)

Comments

Popular posts from this blog

XML Programming using IXMLDOMDOCUMENT in vc++

Get correct OS version on win 8.1 without using GetVesionEx API (deprecated )