Groups | Blog | Home
all groups > inetserver asp components > december 2005 >

inetserver asp components : Passing parameters by reference to a VC COM Object


Marja Ribbers-de Vroed
12/16/2005 2:14:37 PM
I need to change a C++ COM Object so that it will correctly accept =
parameters by reference from an ASP/VBscript webapplication.=20
I'm working from the article found here: =
http://support.microsoft.com/kb/197957/EN-US/, 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 =3D L"This variable is passed by Reference";
*bstrVal =3D 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 =3D VT_BSTR;
vVal->bstrVal =3D 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.

Marja Ribbers-de Vroed
12/16/2005 10:01:28 PM
I found help in another group, and the example function needed tobe =
modified to look like this:

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

AddThis Social Bookmark Button