I have managed to confuse myself whether I should return E_NOTIMPL
or E_NOINTERFACE
from my COM server methods.
I have a class with two functions I have overridden from the class I inherited from, both of those functions do nothing since they aren't really supported at the moment, so I ask should I use "not implemented" or "no interface" for these functions return values?
Does anyone have a general rule of thumb of when to use each?
If you failed to implement an entire interface, then your QueryInterface
could explicitly return E_NOINTERFACE
, so that nobody attempts to call any of its methods, or you could just make all of the methods could return E_NOTIMPL
(it does actually make sense to do this in some edge cases). If you partially implement an interface, then you shouldn't return E_NOINTERFACE
at all.
If a class does not provide a complete implementation of a requested interface the return E_NOINTERFACE. If a class does not implement the body/logic of an interface function then return E_NOTIMPL.
You do (formally) implement the interface, so E_NOINTERFACE
is not for you. It happens that you have methods not usefully implemented, so you should return E_NOTIMPL
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With