Passing parameters by reference to a VC COM Object

Ask a Question related to ASP Components, Design and Development.

  1. #1

    Default Passing parameters by reference to a VC COM Object

    I need to change a C++ COM Object so that it will correctly accept parameters by reference from an ASP/VBscript webapplication.
    I'm working from the article found here: [url]http://support.microsoft.com/kb/197957/EN-US/[/url], as this article descibes my problem with the COM Object exactly.

    The article gives the following original example method:

    STDMETHODIMP CByRefObj::ByRefMethod( BSTR* bstrVal )
    {
    CComBSTR bstrRtnVal = L"This variable is passed by Reference";
    *bstrVal = bstrRtnVal.Detach();
    return S_OK;
    }

    And then at the bottom of the article, they say that the method needs to change so that it will accept a variant instead of a string as the output parameter. And as an example they suggest the following change:

    // Where m_bstr is a BSTR member of SomeComObject.
    vVal->vt = VT_BSTR;
    vVal->bstrVal = m_bstr.Copy();

    But since I don't know much C++ (I didn't write the COM object, but I do have its project sources) I don't understand where to put this in the example method.

    Would anybody here be so kind to rewrite the method above to reflect the suggested change from the article?
    Thanks in advance.

    Regards, Marja
    Marja Ribbers-de Vroed Guest

  2. Similar Questions and Discussions

    1. Dynamically loading user control into Placeholder gives Object reference not set to an instance of an object
      I've created user controls that contain listboxes that are dynamically populated from the database. In the html view of the user control...
    2. Custom Control Problem :: Object reference not set to an instance of an object
      Hi All! I have the following Custom Control file... '########### WebUserControl1.ascx ############# <%@ Control Language="vb"...
    3. [WebMethod] System.NullReferenceException: Object reference not set to an instance of an object.
      Um, this isn't going to work, generally. Web services, as any web app (especially on Windows server 2003) are heavily sandboxed. The method you...
    4. Returning a reference to an existing C++ object as a reference
      Hi All, Given: package x; sub new { return bless {}, $_; } #-- callback() is call by the C++ class (reader_as_cpp_object) #-- whenever...
    5. HELP! Error Loading ASPX : Object Reference not set to an instance object
      Hello, When i run my aspx i get this weird error: System.NullReferenceException: Object reference not set to an instance of an object. at...
  3. #2

    Default Re: Passing parameters by reference to a VC COM Object

    I found help in another group, and the example function needed tobe modified to look like this:

    STDMETHODIMP CByRefObj::ByRefMethod( VARIANT* vVal)
    {
    CComBSTR bstrRtnVal = L"This variable is passed by Reference";
    vVal->vt = VT_BSTR;
    vVal->bstrVal = bstrRtnVal.Detach();
    return S_OK;
    }

    Regards, Marja
    Marja Ribbers-de Vroed Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139