IDispatch And IUnknow


I'm learning COM/DCOM i wanted to know when we need to use IUnknown and IDispatch Standard Interface.



  • You use IUnknown when you want a safe way for pointers to be passed to a function, or to be casted to a superclass/subclass.

    The IDispatch is useful when you want to pass a pointer to something you only want to have certain members, that allows you to dispatch a certain property without knowing the interfaces which provides it.
    E.g. maybe different interfaces have a member called "Caption", you can call it on any of these interfaces and will succeed, while calling it on an interface which doesn't support it will result in an error HRESULT return value.
    When you want a fixed set of members, you just create an IUnknown-inheriting interface, and simply pretend an object of that class only.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion