Click to See Complete Forum and Search --> : ATL COM Method return code


Simon Rose
May 21st, 1999, 03:16 PM
Hi,

I have been beavering away on a simple ATL COM object in order to learn the subject area. The code all compiles, the properties and methods work fine (code wise), but heres the problem.

I have decided to use VB to test the object for 2 reasons. First it's easier, second it's a different language to the one used to develop the object (VC++).

I have a method which needs to return E_FAIL if it fails (this works), or NOERROR if all is good (this works). But I also need to return a number from 1-7 which are catchable reasons why the method failed. However, all VB gets back is 0 or empty, even when I 'doctor' the test to fail in one of my catchable manners.

What am I doing wrong during providing a return value from my method (I thought this would be the easiest bit!) ?

Thanks in advance for any help given,

Simon

David L Hill
May 24th, 1999, 09:55 AM
You can use the Err object in VB to determine more info about the error.

In your method you can create an HRESULT for your method. The FACILITY_ITF is used for interface errors.

Example:

HRESULT hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 7);
return hr;




In VB, you could then use the Err object to extract the error number.

Example:

Dim ecode As Integer
ecode = 2147221504 + Err.Number
MsgBox ecode