[英]How to convert CComBSTR to LPCSTR
I have CComBSTR in my code and have to pass it to function with argument type LPCSTR.我的代码中有 CComBSTR,并且必须将其传递给具有参数类型 LPCSTR 的函数。 How to convert CComBSTR to LPCSTR ?如何将CComBSTR 转换为 LPCSTR ?
There are many ways to do this, but the ATL way would be using Using MFC MBCS/Unicode Conversion Macros :有很多方法可以做到这一点,但 ATL 方法是使用Using MFC MBCS/Unicode Conversion Macros :
void SomeCode()
{
USES_CONVERSION;
CComBSTR bstr(L"hello world");
LPCSTR lp = W2CA(bstr); // bstr is a LPWSTR
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.