Conversion between 'CString' and 'BSTR'


BSTR (Basic string or binary string) is a string data type that is used by COM, Automation, and Interop functions. A BSTR is a composite data type that consists of a length prefix, a data string, and a terminator.

Use the AllocSysString member function of the CString to convert from CString to BSTR:

Code:
        CString cs("Hello");
        BSTR bstr = cs.AllocSysString();

Note: If you use the 'BSTR' by yourself, dont forget to call '::SysFreeString()' when you're done with it.

No comments:

Post a Comment

Caching is a technique used to store frequently accessed data in a temporary storage layer to improve system performance and reduce latency....