M
Marja Ribbers-de Vroed
I need to change a C++ COM Object so that it will correctly accept parameters by reference from a classic 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.
I think it should look like this:
STDMETHODIMP CByRefObj::ByRefMethod( VARIANT* bstrVal )
{
CComBSTR bstrRtnVal = L"This variable is passed by Reference";
vVal->vt = VT_BSTR;
vVal->bstrVal = bstrRtnVal.Detach();
return S_OK;
}
Is this correct?
Regards, Marja
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.
I think it should look like this:
STDMETHODIMP CByRefObj::ByRefMethod( VARIANT* bstrVal )
{
CComBSTR bstrRtnVal = L"This variable is passed by Reference";
vVal->vt = VT_BSTR;
vVal->bstrVal = bstrRtnVal.Detach();
return S_OK;
}
Is this correct?
Regards, Marja