Click here to Skip to main content
15,888,286 members
Home / Discussions / COM
   

COM

 
QuestionHow to add MFC support to ATL EXE Project? Pin
14-Jun-01 5:10
suss14-Jun-01 5:10 
QuestionLimitation of .tlb import in VC++? Pin
14-Jun-01 4:03
suss14-Jun-01 4:03 
AnswerRe: Limitation of .tlb import in VC++? Pin
J Patel21-Jun-01 11:38
J Patel21-Jun-01 11:38 
Questionwhat does ESP means? Pin
14-Jun-01 3:00
suss14-Jun-01 3:00 
AnswerRe: what does ESP means? Pin
Kevin Perry (msft)19-Jun-01 19:06
Kevin Perry (msft)19-Jun-01 19:06 
Generalexception handling framework Pin
praveen prabhakar13-Jun-01 14:05
praveen prabhakar13-Jun-01 14:05 
General[dual] (un)happiness Pin
13-Jun-01 2:01
suss13-Jun-01 2:01 
GeneralRe: [dual] (un)happiness Pin
3-Jul-01 5:22
suss3-Jul-01 5:22 
Hey Daniel,

I'll try and help with what I understand about disp and dual interfaces.

1. Disp interfaces are not derived from IDispatch, they are IDispatch. The automation client will only be aware of the disp interface, and this wil be the only means of communication between automation clients and your object.

2. Disp interfaces will use invoke to call methods of your object, and they will use GetIDsofNames to discover at run time the methods and properties exposed through the IDispatch interface. IDispatch is in fact derived from IUnknown, however, as are all COM interfaces. So, you are in fact using a VTable if you use IDispatch, but you are using a VTable to the IDispatch methods, not the specific methods of your interface (IMyObject or whatever).

3. Using dual means that your object will implement an IDispatch interface as well as a custom interface. Methods of your object will be available both through the IDispatch interface and through its custom interface. Methods accessed through the custom interface will be accessible directly through the interface pointer (VTable), while methods accessed through the IDispatch will have to be accessed through the slower Invoke method of IDispatch. The invoke method basically just imposes the same signature on all of the methods of your object by packaging all parameters to the method in a variant array. So you lose speed with the dispatch, and also sacrifice a little bit of type safety, in that it's no longer possible to check the parameters to a method at compile time, so it's possible to send the wrong number and types of arguments to a call to IDispatch::Invoke, and get a return value of E_INVALIDARG. A single interface does not use both invoke and a direct VTable. The IDispatch interface exposed by your object implements the Invoke, etc., while the custom interface(s) expose whatever methods they wish though the VTable.

Event source interfaces are pure disp interfaces by convention, not dual or custom. The event source interface should be a separate disp interface. Note that this is an outgoing interface, so this means that the event interface is published by your object, but the methods are implemented by the object that wishes to receive the events. When your object fires an event, it is actually calling a method of the source interface implemented on the receiving object. You may implement multiple event sources on a single object, but I think usually one is probably enough.

Using a dual interface allows C++ or other custom clients the ability to access the faster custom interface of your object, while at the same time allowing automation clients the ability to use your object through its dispatch interface (things like VBScript). When you use the dual interface, there's no extra work required on your part to support IDispatch, so it's basically for free. If your object will never be used through an IDispatch interface, there is no benefit to using dual interfaces, but they offer the most flexibility and portability.

I hope that helps.
GeneralRich Edit Controls - Embedding Files Pin
Steve Thresher12-Jun-01 1:51
Steve Thresher12-Jun-01 1:51 
GeneralUnable to locate assembly error Pin
11-Jun-01 22:31
suss11-Jun-01 22:31 
GeneralDefault parameter values Pin
Christian Dahl10-Jun-01 23:29
Christian Dahl10-Jun-01 23:29 
GeneralRe: Default parameter values Pin
Ulf Öhlén10-Jun-01 23:47
Ulf Öhlén10-Jun-01 23:47 
GeneralConfiguring a COM+ Server Application as an NT Service Pin
12ways10-Jun-01 22:18
12ways10-Jun-01 22:18 
QuestionHow to get the com-GUID directly from its dll or exe file Pin
9-Jun-01 19:02
suss9-Jun-01 19:02 
AnswerRe: How to get the com-GUID directly from its dll or exe file Pin
MikeG18-Jun-01 6:17
MikeG18-Jun-01 6:17 
QuestionHow to get the com-GUID directly from its dll or exe file Pin
9-Jun-01 18:57
suss9-Jun-01 18:57 
QuestionHow to get the com-GUID directly from its dll or exe file Pin
9-Jun-01 18:57
suss9-Jun-01 18:57 
GeneralAutomatic help creation for a COM/ActiveX type library Pin
8-Jun-01 5:27
suss8-Jun-01 5:27 
GeneralI am new Pin
8-Jun-01 0:26
suss8-Jun-01 0:26 
GeneralDetect running servers Pin
Brian van der Beek8-Jun-01 0:00
Brian van der Beek8-Jun-01 0:00 
GeneralATL Dialogs Pin
AndyC7-Jun-01 8:56
AndyC7-Jun-01 8:56 
GeneralRe: ATL Dialogs Pin
Michael P Butler7-Jun-01 22:29
Michael P Butler7-Jun-01 22:29 
GeneralRe: ATL Dialogs Pin
Amit Dey8-Jun-01 2:42
Amit Dey8-Jun-01 2:42 
GeneralVisual C++ COM Component in Vb/ASP Pin
Krush7-Jun-01 7:35
Krush7-Jun-01 7:35 
GeneralRe: Visual C++ COM Component in Vb/ASP Pin
Carlos Antollini7-Jun-01 7:45
Carlos Antollini7-Jun-01 7:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.