Link to home
Start Free TrialLog in
Avatar of loyaliser
loyaliserFlag for United States of America

asked on

Converting variables...

How do I copy a BSTR variable to a char variable?

How do I copy a char variable (of array type) to a BSTR variable?
Avatar of viktornet
viktornet
Flag of United States of America image

What's a BSTR?
Avatar of loyaliser

ASKER

BSTR is a COM variable type. I am building a COM in Visual C++ 6.0 and one of my functions accepts a parameter of type BSTR. I need to convert the BSTR variable to a char so that I can pass it to a function that accepts a char parameter.

That's it... make any sense? Thanks...
As far as I know BSTR is similar to the String data type, however, I don't know if it shares the same API methods.
Avatar of fkurucz
fkurucz

the class _bstr_t defined in <comdef.h> automates the conversion from and to BSTR or char*.

intern the following functions are used:

 BSTR _com_util::ConvertStringToBSTR(const char* pSrc)

 char* _com_util::ConvertBSTRToString(BSTR pSrc)

bye,
  feri
ASKER CERTIFIED SOLUTION
Avatar of rayb
rayb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah... I need the method that works in the ATL, because the code is within an ATL COM object.

Thanks...