Where AddRef and Release don't do anything and QueryInterface fails on every attempt. (meaning it sets *ppvObject to NULL and returns S_FALSE).
The rest of the class is comprised of the implementation of another COM interface namely ITextHost. Now I'm creating a COM object that takes an ITextHost interface as a parameter. Is it OK to pass it static_cast<ITextHost*>(this) ?
My C++ class does not need to be a creatable COM object. It only needs to be called through COM once it has been created. It is not supposed to be derived from IDispatch, but only from IUnknown (hence QueryInterface, AddRef and Release)
My guess is that I should at least allow QueryInterface to succeed for IUnknown and ITextHost.
BUT, provided this, is this really supposed to work ? It does work in my example code (on my machine), but it seems a bit dodgy.
hello,
If u want to use ur C++ class internal to ur COM component why ur deriving it from IUnknown.
just make it plain C++ class which implementing ur custom interface.
Your code will work as long as you are taking special care of what your a doing with the ITextHost interface pointer.
But my question is why are you taking the risk of running into a problem?
Why don't you create a simple COM object which is "empty" besides of implementing the ITextHost interface? You will be on a clean way, it will have no overhead, no special considerations...
Originally posted by alpha137
But my question is why are you taking the risk of running into a problem?
Why don't you create a simple COM object which is "empty" besides of implementing the ITextHost interface? You will be on a clean way, it will have no overhead, no special considerations...
Well, the point is that I would like to use it in a project where the class implementing ITextHost is only one of many in an inheritance tree. If you have tried inheritence in COM, you know why I prefer doing this.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.