none
Need help debugging COM event handling RRS feed

  • Question

  • I'm trying to hook into MAPILogonComplete in ApplicationEvents_11 interface but failing to do so. I set a bp on OnMapiLogonComplete() and it never hits. OnConnection is getting called and DispEventAdvise returns S_OK.

    What do you think I am doing wrong?

    --- Header file: ---
    extern _ATL_FUNC_INFO OnMapiLogOnCompleteInfo;
    
    class ATL_NO_VTABLE CAddIn :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CAddIn, &CLSID_AddIn>,
    public IDispatchImpl<IFromCloud, &IID_IAddIn, &LIBID_AddInLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
    public IDispEventSimpleImpl<1, CAddIn, &__uuidof(Outlook::ApplicationEvents_11)>,
    public IDTImpl,
    public RibbonImpl,
    public CallbackImpl {
    public:
        CAddIn() {}
        BEGIN_SINK_MAP(CAddIn)
        	SINK_ENTRY_INFO(1,__uuidof(Outlook::ApplicationEvents_11), 0x0000fa90,OnMapiLogonComplete,&OnMapiLogOnCompleteInfo)
        END_SINK_MAP()
    
    
    public:
        HRESULT OnMapiLogonComplete();
    private:
        CComPtr<Outlook::_Application> m_App;
    
    --- Cpp file:---
    _ATL_FUNC_INFO OnMapiLogonCompleteInfo  = {CC_STDCALL, VT_HRESULT, 0, {}};
    
    
    HRESULT CAddIn::OnMapiLogonComplete() {
        return S_OK;
    }
    
    STDMETHODIMP CAddIn::OnConnection(LPDISPATCH Application, ext_ConnectMode ConnectMode, LPDISPATCH AddInInst, SAFEARRAY * * custom){
        CComQIPtr<Outlook::_Application> pOutlook = Application;
        m_App = pOutlook;
        HRESULT hRes = DispEventAdvise(m_App);
        return S_OK;
    }

    Saturday, November 14, 2015 1:42 AM

Answers

  • _ATL_FUNC_INFO OnMapiLogonCompleteInfo  = {CC_STDCALL, VT_HRESULT, 0, {}};

    This is not correct.

    The struct should be:

    _ATL_FUNC_INFO OnMapiLogonCompleteInfo = {CC_STDCALL, VT_EMPTY, 0};


    • Edited by RLWA32 Saturday, November 14, 2015 2:52 AM
    • Marked as answer by Joel_Z Saturday, November 14, 2015 3:42 AM
    Saturday, November 14, 2015 2:52 AM

All replies

  • As I mentioned in a reply to another of your posts, it is possible that Application.Session.MAPIOBJECT might already be available by the time your addin starts up. If it is, just use it. If not, wait for OnMAPILogonComplete.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Saturday, November 14, 2015 1:55 AM
  • As I mentioned in a reply to another of your posts, it is possible that Application.Session.MAPIOBJECT might already be available by the time your addin starts up. If it is, just use it. If not, wait for OnMAPILogonComplete.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    I'll need to look into Application.Session.MAPIOBJECT to hear what you mean. For this post, I'm also needing to know if there is a bug in the code that would prevent the handler from being called. I need to understand if I'm doing this right so that I can create handlers for other things such as when email arrives.
    Saturday, November 14, 2015 2:26 AM
  • _ATL_FUNC_INFO OnMapiLogonCompleteInfo  = {CC_STDCALL, VT_HRESULT, 0, {}};

    This is not correct.

    The struct should be:

    _ATL_FUNC_INFO OnMapiLogonCompleteInfo = {CC_STDCALL, VT_EMPTY, 0};


    • Edited by RLWA32 Saturday, November 14, 2015 2:52 AM
    • Marked as answer by Joel_Z Saturday, November 14, 2015 3:42 AM
    Saturday, November 14, 2015 2:52 AM