CHAR:
To BSTR:
_ Com_util: convertstringtobstr
Allocsystemstring of cstring
To _ bstr_t:
_ Bstr_t Constructor
To ccombstr:
Ccombstr Constructor
BSTR:
To char:
_ Com_util: convertbstrtostring
To _ bstr_t:
_ Bstr_t Constructor
To ccombstr:
Ccombstr Constructor
_ Bstr_t:
To char:
Lpctstr Operator
To BSTR:
BSTR Operator
To ccombstr:
Use the BSTR operator to convert to BSTR, and then use the ccombstr constructor.
Ccombstr:
To char:
Lpctstr Operator
To BSTR:
BSTR Operator
To _ bstr_t:
Use the BSTR operator or directly take the m_str member as the _ bstr_t constructor.
Cstring:
# Include "atlbase. H"
BSTR test1 =: sysallocstring (L "test OK !!! ");
Ccombstr test;
Test. Attach (test1); // = "adsfasdfsdf ";
Uses_conversion;
Cstring STR;
STR = w2a (test );
MessageBox (STR, mb_ OK );
Because BSTR m_str, a data member in ccombstr, is public and the & operator is overloaded, it is suitable for use as a function that uses BSTR as the outgoing parameter. However, pay attention to the memory leakage problem, do not use assigned ccombstr as an outgoing Parameter