Re: Dual interface



Thanks SvenC,


1.

No. If a component *only* (what do you mean with directly?) implements
and exposes (through QueryInterace) IDispatch (it must expose IUnknown
as well!) then you can use the Invoke method of IDispatch to use the
methods and properties which the COM component implements. Which
methods and properties are available could come in a typelib or in written
documentation

Sorry for my bad English, and I show here some code to clarify.

What I mean is component coclass CFoo is defined as CFoo:IDispatch, i.e.
CFoo implements IDispatch directly. And CFoo only exposes IDispatch and
IUnknown and internal implementation methods could only be called by
IDispatch.Invoke. Do you agree? :-)

I am confused about what do you mean "could come in a typelib or in written
documentation". Through typelib or through some documentation, we could have
means to call the internal implementation methods of CFoo not through
IDispatch.Invoke? What is your point to introduce typelib and document here?
:-)

2.

All COM components must implement IUnkown "by law".

I think the law should be every interface of the COM component implements,
must inherits IUnknown or be IUnknown directly. Not COM component must
implment IUnknown. For example, do you think it is legal to define a
component called CGoo, which implements IGoo and IUnknown, but IGoo is not
inheriting from IUnknown? :-)

3.

Almost. Again: no interface implements anything. So your custom
interface does not implement IUnknown. It derives from IUnknown
and so your C++ class is forced to implement the IUnknown
methods as well.

Sorry. My bad terminology if I speak too fast. :-)

Here is the corrected version of what I want to say. Do you think it is
correct now?

--------------------
3. If a component implements a customized interface, then the
customized interface derives from IUnknown, then we could invoke the
component's member methods through QueryInterface to get the
customized interface, and using the vtable in the customized
interface to invoke member methods. But still one way, so it is not
dual interface.
--------------------

4.

4. If a component implements a customized interface, then the
customized interface implements IDispatch, then we could invoke the
component's member methods through QueryInterface to get the
customized interface, and using the vtable in the customized
interface to invoke member methods, and also we could invoke through
IDispatch.Invoke. Two ways to invoke it, so called dual interface.

Same problem with your wording of interfaces implementing something.

I have corrected my wording. Could you review whether the following
statements are correct now? :-)

--------------------
If a component implements a customized interface, then the
customized interface derives from IDispatch, then we could invoke the
component's member methods through QueryInterface to get the
customized interface, and using the vtable in the customized
interface to invoke member methods, and also we could invoke through
IDispatch.Invoke. Two ways to invoke it, so called dual interface.
--------------------


have a great weekend,
George
.



Relevant Pages

  • Re: Dual interface
    ... its member methods through IDispatch.Invoke -- only one way, ... IUnknown this component /might/ be of no use. ... customized interface implements IUnknown, then we could invoke the ...
    (microsoft.public.vc.language)
  • Re: Dual interface
    ... If a component implements IDispatch directly, ... IUnknown, so every COM object had QueryInterface/AddRef/Release. ... interface implements IUnknown, then we could invoke the component's member ... vtable in the customized interface to invoke member methods. ...
    (microsoft.public.vc.language)
  • Marshalling a marshalled interface pointer
    ... component that contains this object holds a container of IUnknown ... It also exposes the interface 'IDiscussions' which provides the method ... Another 'ChatServer' is started and registers itself with the ... ChatBroker with the name "Server2". ...
    (microsoft.public.vc.atl)
  • Re: IUnknown interface
    ... both directly derived from IUnknown. ... two different implementations (note that usually both interface tables ... ULONG STDMETHODCALLTYPE Release ... virtual HRESULT DoSomething ...
    (microsoft.public.vc.language)
  • Re: ATL and object aggregation (more)
    ... I don't think you should call Releaseon an interface's pointer. ... an helper method that is called by the 'true' COM interface method ... > It's wrong because the IUnknown interface will be lost during the Query ... then the IInObj3Ptr InObj3Ptr constructor is ...
    (microsoft.public.vc.atl)