tags:

views:

148

answers:

2

When you create a type library in Delphi and create an interface and the associated CoClass, Delphi also creates matching dispinterface declarations.

My understanding is that these relate to the fact that my interface derives from IDispatch, but I thought that TAutoObject implements everything needed for IDispatch. So my question is threefold:

  1. What is the dispinterface used for?
  2. Why is it needed?
  3. How does one use it?
+3  A: 

COM is like VOODOO you should only get involved if you are willing to be consumed by its power!

COM really is an enormously complicated subject when you get down to the nitty gritty. However on the surface an implementation like Delphis gives you all the tools you need to use it very simply. However if you are interested in getting down and dirty there are some very good books on COM including (from a Delphi perspective) Delphi Com Programming.

To really simplify and try to answer your questions.

  1. VB was not able to deal with IUnknown due to limitations in its use of pointers (or something like that) so Microsoft added dispatch or disp interaces which allowed VB to interact with COM objects. These dispinterfaces then became the basis of Ole Automation objects (a branch of COM).
  2. To Let VB work with COM
  3. Let Delphi do that for you.
Toby Allen
VB5/6 do not need dispinterfaces anymore. VBScript/JScript do.
wqw
how can they not need dispinterfaces anymore? VB5/6 havent changed. I'm not sure I understand what you mean.
Toby Allen
:-)) VB4 did. VB6 can call methods of IUnknown only inherited interfaces like a breeze. Can't cast these to Object though.
wqw
+2  A: 

TechVanguards.com is Delphi & COM website with really good content. It have tutorials and some advanced examples.
You'll find informations about disp interfaces and examples how to work with them.

zendar