Re: How to pass a reference to a CComBSTR
- From: "Heinz Ozwirk" <hozwirk.SPAM@xxxxxxxx>
- Date: Sun, 31 Jul 2005 09:40:25 +0200
"Steve Franks" <please@xxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:_t6dnYV4EPK_V3bfRVn-qg@xxxxxxxxxxxxxx
>I have a CComBSTR variable in function A. I want to pass this variable to
>function B by REFERENCE, so that function B can update this variable with a
>new string it calculates.
>
> I'm passing in my CComBSTR like this: myfunction(& myCComBSTRvar)
> and myfunction looks like this:
> void myfunction(CComBSTR *myCComBSTRvarToUpdate) {}
This is not passing by reference - you are passing pointers. To pass by
reference yous should declare myfunction as
void myfunction(CComBSTR& myModifiableVariable)...
and call it like
myfunction(myCComBSTRvar);
Some wise guy at MS thought it to be a good idea to overload operator& to
make a CComBSTR easyly mix with plain BSTR. But by doing that he made it
impossible to get the address of a CComBSTR itself. If you only use CComBSTR
as a wrapper for BSTR, you should have a look at _bstr_t.
> I am using Visual Studio 6.0 and that is my only option. What is the MOST
> EFFICIENT way I can handle this need? I read something from Microsoft
> about using a "container" if you need to pass a CComBSTR by reference, but
> I'm not sure what they mean. Can someone provide a quick example of that?
There is some class called CAdapt somewhere in ATL...
HTH
Heinz
.
- Follow-Ups:
- Re: How to pass a reference to a CComBSTR
- From: Egbert Nierop \(MVP for IIS\)
- Re: How to pass a reference to a CComBSTR
- References:
- How to pass a reference to a CComBSTR
- From: Steve Franks
- How to pass a reference to a CComBSTR
- Prev by Date: Re: How to pass a reference to a CComBSTR
- Next by Date: Re: How to pass a reference to a CComBSTR
- Previous by thread: Re: Improved CComBSTR
- Next by thread: Re: How to pass a reference to a CComBSTR
- Index(es):
Relevant Pages
|