Re: Raise Errors from non-coclasses
Barzo <dbarzo@gmail.com> wrote:
On 4 Mag, 13:43, "Igor Tandetnik" <itandet...@mvps.org> wrote:
Barzo wrote:
Ok, now I have to raise a COM error from the non-coclass
implementation file.
AtlReportError, pass GUID_NULL for CLSID parameter.
Like show here:
http://support.microsoft.com/?scid=kb%3Ben-us%3B827994&x=11&y=10
I use this line to raise an "Invalid Index" to a VB6 client:
return AtlReportError(GUID_NULL, (LPCOLESTR)0, IID_IAudioRecorder,
DISP_E_BADINDEX);
But the VB6 Err object shows:
Err.Number = -2147352565 (Which is correctly 0x8002000B =
DISP_E_BADINDEX)
Err.Description = Unknown Error
Hmm. The way AtlReportError (or, to be precise, AtlSetErrorInfo) is =
written, it never sets the description to NULL. If you try to pass NULL =
to it (as you did), it generates a default string "Unknown Error" (as =
you observed).
I suppose you'll have to write your own helper function similar to =
AtlSetErrorInfo. You can look at its implementation in atlcom.h
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not =
necessarily a good idea. It is hard to be sure where they are going to =
land, and it could be dangerous sitting under them as they fly overhead. =
-- RFC 1925