The purpose of ISupportErrorInfo is to make sure it is set by your object,
and not some bogus value from previous calls. You see, once set by
SetErrorInfo, the error information persists until replaced by another
error. Suppose you call a method on an object that supports error info, and
the method returns failed HRESULT. You retrieve error info and all is good.
Now you call an object that doesn't support error info, and it returns
failed HRESULT. If you now check error info, you'll get one from the
previous call. So, before relying on it, you should check whether the object
you just called supports error info - then you know that the info you've
just retrieved originates from it. That's where ISupportErrorInfo comes into
play. I believe VB does check this interface.
The other side of this issue is that if an object promises (through
ISupportErrorInfo) that its interface supports error info, it should set it
whenever it returns failed HRESULT from any method of that interface.
Otherwise the client may associate bogus error info with this failure.
--
With best wishes,
Igor Tandetnik
Quote:
> I have an object (no IDispath or Dual) support ISupportErrorInfo with
> InterfaceSupportsErrorInfo implemented, so I can get error message from
> Error in VB. However even if I take off ISupportErrorInfo and
> InterfaceSupportsErrorInfo , I can still get the Error information which I
> thought not avaible any more.
> Any comments? Thanks.
> Jim