-
vTables/Interfaces
Hi,
I would be grateful if someone would help me with a vTable question?
If an object exposes 2 duel interfaces would the vTables be laid out like this?
IUnknown
QueryInterface
AddRef
Release
IDispatch
QueryInterface
AddRef
Release
GetTypeInfoCount
GetTypeInfo
GetIDsOfNames
Invoke
_cClass1
QueryInterface
AddRef
Release
GetTypeInfoCount
GetTypeInfo
GetIDsOfNames
Invoke
Class1_Method1
Class1_Method2
_cClass2
QueryInterface
AddRef
Release
GetTypeInfoCount
GetTypeInfo
GetIDsOfNames
Invoke
Class2_Method1
Class2_Method2
Dan Appleman has an illustration of an object exposing 2 interfaces.
He has each one with a representation of its own IDispatch, but only one
implementation of IUnknown.
Example
IUnknown
IDispatch for _cClass1
_cClass1
IDispatch for _cClass2
_cClass2
Why 2 IDispatches? Would the vTables for this look like the ones above with an extra Idispatch?
Thanks for any help you can give!
:) :)
-
Get a copy of OleView.exe from MSDN. Then, open up controls, and then select one - right-click.
What you see there is the .idl file representation of the of the interfaces. There are often several references to IDispatch, or some other interface. Objects can expose as many as forty interfaces. Look in MSDN for COleControl and look at the interface list it exports.
The best book on interfaces is COM and COM+ from MicroSoft Press - it assumes you know C.
vtables are constructed by linking, not by how the object interface(s) are defined in the .odl file.
-
Thanks for the reply. I greatly appreciate your input. :)
I am reading COM+ with VB6 by Microsoft Press. The only part I'm having some trouble with refers to interfaces. :confused:
If an object exports IUnknown, IDispatch, and a Dual Interface. What is the advantage of having the dual interface over an interface derived directly from IUnknown? Can't the regular IDispatch provide any functionality needed?
If I have a reference to a dual interface and I try to get an IDispatch reference do I get an IDispatch reference to the same interface I was in or to the "real" IDispatch?
In one breath it says to derive my custom interfaces from IDispatch to support scripting clients and in the next it says don't use more than one interface derived from IDispatch. I guess I'm not sure of the advantages of having a dual interface when the other interfaces are already exported.
I know you probably don't want to teach a whole class on the matter, but if you could help me out with a brief lesson, I would be greatful.
Thanks for any help.
:) :)