Thread: dual interface for IDispatch

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    dual interface for IDispatch

    Hello everyone,


    Could anyone show me a sample or where to find dual interface implementation for IDispatch please?

    I have seached for MSDN and Google for half an hour and seems all I could get are MFC based.

    Any non-MFC and non-ATL (pure C++) sample?


    thanks in advance,
    George

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    I would suspect that it's too tiresome for people to do that.

    Implementing the dual interface approach looks like this:
    1) Implement the proper interfaces.
    2) Implement IDispatch:
    2.1) Build a table of the methods and their method IDs.
    2.2) Have GetIDsOfNames look up info from this table and return it.
    2.3) Have Invoke unpack the arguments and pass them to the appropriate real method.

    As you see, the entire step 2 is mind-numbingly boring and always the same. That's why it's better to let a wizard do it.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks CornedBee,


    I have a further question, sometimes I notice that the component actually implements the dual interface, but in the IDL file, "dual" property is not added to the interface property.

    1. Is it good practice?

    2. What is the purpose of doing so? Force user to use IDispatch other than efficient vtable?

    3. Could we use vtable even if dual property is not added to interface? For example, using QueryInterface to get some interface IIX other than IDispatch and IUnknown? Then invokes the functions in interface IIX through vtable?


    regards,
    George

    Quote Originally Posted by CornedBee View Post
    I would suspect that it's too tiresome for people to do that.

    Implementing the dual interface approach looks like this:
    1) Implement the proper interfaces.
    2) Implement IDispatch:
    2.1) Build a table of the methods and their method IDs.
    2.2) Have GetIDsOfNames look up info from this table and return it.
    2.3) Have Invoke unpack the arguments and pass them to the appropriate real method.

    As you see, the entire step 2 is mind-numbingly boring and always the same. That's why it's better to let a wizard do it.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    I have no idea.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Good answer, CornedBee. :-)


    Let us see other people's comments.

    Quote Originally Posted by CornedBee View Post
    I have no idea.

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 10:13 AM
  2. Calling IRichEditOle interface methods
    By Niara in forum C Programming
    Replies: 2
    Last Post: 01-16-2009, 01:23 PM
  3. Cannot get interface flags: Invalid argument
    By nasim751 in forum C Programming
    Replies: 1
    Last Post: 04-15-2008, 02:27 AM
  4. buying a laptop ; intel dual core?
    By BobMcGee123 in forum A Brief History of Cprogramming.com
    Replies: 27
    Last Post: 07-30-2006, 02:28 PM
  5. OOP in C
    By lyx in forum C Programming
    Replies: 4
    Last Post: 11-23-2003, 01:12 PM