Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Components / December 2005



Tip: Looking for answers? Try searching our database.

Passing parameters by reference to a VC COM Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marja Ribbers-de Vroed - 16 Dec 2005 13:14 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.