Re: LPDISPATCH or IDispatch*

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Semut (ant_yio_at_hotmail.com)
Date: 03/10/05


Date: Thu, 10 Mar 2005 10:59:53 +0800

Ok, please bear with me, I am still learning the ATL and COM.

I am actually programming a COM Addin for Outlook.

I want to store everything as LDISPATCH into a STL N-Ary Tree container for
later processing.
I use CComQIPtr to QI my LDISPATCH in the N-Ary tree for my processing.
The LDISPATCH inside the container will get Release one by one after
completing the processing by calling lpDisp->Release, then lpDisp = NULL.

I have few ways to obtain the LDISPATCH.

Like through the COleDispatchDriver::InvokeHelper from an existing
MAPIFolder COleDispatchDriver.
The MAPIFolders object are obtained through the Outlook :: _Application
which I obtain in the OnConnection (IDispatch * Application, ext_ConnectMode
ConnectMode, IDispatch * AddInInst, SAFEARRAY * * custom) event handler.

E.g.

LPDISPATCH result;
 static BYTE parms[] =
  VTS_VARIANT;
 oleDisDriver.InvokeHelper(0x51, DISPATCH_METHOD, VT_DISPATCH,
(void*)&result, parms,
  &Index);
 return result;

or

Through existing CComPtr MAPIFolder object.

E.g.

CComPtr<Outlook::_NameSpace> spNameSpace;
CComPtr < Outlook :: MAPIFolder > spMAPI;
spNameSpace->GetDefaultFolder(Outlook::olFolderCalendar, &spMAPI);

LPDISPATCH lpDis = spMAPI.Detach();

"Kim Gräsman" <kim@mvps.org> wrote in message
news:uW4$IFKJFHA.2700@TK2MSFTNGP09.phx.gbl...
Hi Semut,

> What is "home" apartment for lpDisp?

The apartment where the object it points to was created.
Let's try and be more practical... Where did you get the IDispatch pointer?
Did you CoCreate it yourself or was it passed to you from somewhere?

> I guess I need a COM book, what is your recommendation for references?

Essential COM is always good: http://www.amazon.com/o/ASIN/0201634465

-- 
Best regards,
Kim Gräsman