Re: Does an event sink need to support QI on the implemented interface, or just IDispatch?

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

From: david hurkle (david)
Date: 08/09/04


Date: Mon, 9 Aug 2004 11:57:30 +1000

Yes, that's pretty close, and I can only handle IDispatch with genuine
DISPIDs, not vtables.

Did you mean IProvideClassInfo or IProvideClassInfo2? What would I use the
GUID for?

I guess you mean that I should get the
ITypeInfo->GetTypeAttr()->TYPEATTR.typekind and check it's TKIND_DISPATCH?

I could do that, but I already did it at compile time (I only implement
TKIND_DISPATCH). Will it have changed?

If it's actually a dual interface, how can I be sure it will call using the
IDispatch method?

DavidB

"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:eRtYwUBfEHA.1424@tk2msftngp13.phx.gbl...
> Are you implementing the sink at runtime? If not, you can
> always look at the type library to verify it's a pure dispinterface.
> If it's a COM interface, you must implement it accordingly too.
>
> Now, if you are talking about dynamically implementing sinks
> off a type library (like developing a scripting engine for example),
> you can check the type library at runtime. In fact you need to,
> so you can reject (or perhaps properly implement?) real COM
> event interfaces (derived from IUnknown). IProvideClassInfo2
> has been invented with this purpose in mind.
>
> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@mvps.org
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
> "DavidB" <davidb3@Ihatespam.hurkle.com> wrote in message
> news:O5VQc.37019$K53.12415@news-server.bigpond.net.au...
> > So how do I protect myself against claiming to implement an interface I
> > really don't? I thought responding only to IDispatch would do that, but
> > getting called on a vtable I don't have (or actually contains different
> > functions) is not a nice prospect!
> >
> > DavidB
> >
> > "Alexander Nickolov" <agnickolov@mvps.org> wrote in message
> > news:uHCtHR9eEHA.3520@TK2MSFTNGP10.phx.gbl...
> > > An event interface cannot be dual. And yes, you are required to
> > > report it via IUnknown::QueryInterface. However, the event
> > > interface may be a regular COM interface deriving from IUnknown,
> > > so beware :)...
> > >
> > > --
> > > =====================================
> > > Alexander Nickolov
> > > Microsoft MVP [VC], MCSD
> > > email: agnickolov@mvps.org
> > > MVP VC FAQ: http://www.mvps.org/vcfaq
> > > =====================================
> > >
> > > "DavidB" <davidb3@Ihatespam.hurkle.com> wrote in message
> > > news:4vJQc.36112$K53.4208@news-server.bigpond.net.au...
> > > > When implementing an event sink (say IAppEvents) in a client, it
seems
> > > that
> > > > the server may (or may not) QI the sink for the IID (eg
> IID_IAppEvents).
> > > >
> > > > Most servers I have tested just QI for IDispatch. That works just
> fine.
> > > This
> > > > seems correct, since Advise() is only required to provide an
> > > implementation
> > > > of IDispatch, not something inheriting from it.
> > > >
> > > > A server I built with ATL QI's for IAppEvents, and won't connect
> unless
> > > it's
> > > > found. Is this correct?
> > > >
> > > > It's pretty scary to say you implement an interface when you don't
> know
> > > what
> > > > you're going to be asked to do! What if it's dual?
> > > >
> > > > DavidB
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: How to override virtual function in ATL ?
    ... I found the option "Implement Interface" when I right click on the ... class, If I want to Implement IDispatch interface, then How can I ... I am trying to implement an event sink. ... > object and calls its methods/properties. ...
    (microsoft.public.vc.atl)
  • Re: Does an event sink need to support QI on the implemented interface, or just IDispatch?
    ... Are you implementing the sink at runtime? ... If it's a COM interface, you must implement it accordingly too. ... "DavidB" wrote in message ... >>> Most servers I have tested just QI for IDispatch. ...
    (microsoft.public.win32.programmer.ole)
  • Re: The remote procedure call failed for new method in ATL COM+ ob
    ... interface to support the new method. ... That is why you see interface names like: ... IProvideClassInfo and IProvideClassInfo2 ... IDispatch and IDispatchEx ...
    (microsoft.public.vc.atl)
  • IDispatch* , COM Server(LOCAL_SERVER), event data and C#.NET
    ... I have one main inbound interface called ... If IDispatch is the answer, I already did the following, ... I did code following C++ wrapper class for the _ICallInfo impl. ... // object before calling the base class. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Problems with IDispatchImpl
    ... you have your own dual interface defined in another type library. ... You have to check if this IApplication is indeed a dual interface. ... IDispatch by hand (based on your previous post, ... > The IDispatch methods are indeed implemented by IDispatchImpl, ...
    (microsoft.public.vc.atl)