I'm stuck on this one.
Given three variables:
- an
IDispatch*
to a connectable object - the
IID
(DIID) of an outgoing dispinterface on that object - the name of a member defined by the dispinterface
How can resolve the name to a DISPID?
pDispatch->GetIDsOfNames(...)
returnsDISP_E_UNKNOWNNAME
, as I would expect (outgoing interfaces aren't implemented by the connectable object)- I need to support scenarios where 0 clients have yet connected to the outgoing interface, so I can't enumerate the existing connection points in order to call
GetIDsOfNames
on one of them (I'm not even sure this would work) - In order to perform manual reflection, I would need the dispinterface's
ITypeInfo
. I could get this from the coclass'sITypeInfo
. HoweverpDispatch->GetTypeInfo(0, ...)
returns theITypeInfo
for theIDispatch
implementation (as per the documentation), not theITypeInfo
for the coclass. (And there are no otherITypeInfo
s exposed by this object'sIDispatch
implementation.)
If the object is "quite standard", then it should be possible.
From the object/IDispatch interface, you should be able to get to the TLB (type library). From the type library, you should be able to browse all coclasses, and get interfaces that these coclasses implement. You need to get to interface you have the IID for, browse the member and get the one you're interested.
There are many cases where this just won't work. Here is a console sample I've put up that works with a shell object. I've written it in C# because it's easier, but there's nothing you can't do with a decent language. I've used an old TLBINF32.DLL com utility library (only x86 unfortunately) I talk about in my answer to this question here on SO: How to read COM TypeLib with C# or C++?