CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1

    ATL COM Method return code

    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




  2. #2
    Join Date
    May 1999
    Location
    Indiana
    Posts
    21

    Re: ATL COM Method return code

    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







Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured