BSTR
●Java字符串是以0结束的Unicode字符
数组。
需要定义一种通用的字符串类型,可以很容易的匹配到不同
编程语言。
在
C++
中,就是
BSTR。
1. char*转换成BSTR
方法一,使用SysAllocString等API函数。例如:
BSTR bstrText = ::SysAllocString(L"Test");
2 . CString转换成BSTR
通常是通过使用CStringT::AllocSysString来实现。例如:
CString str("This is a test");
BSTR bstrText = str.AllocSysString();
…
SysFreeString(bstrText); // 用完释放