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: 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 = 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 - 16 Dec 2005 21:01 GMT
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