将 BSTR 转换为 LPCWSTR [英] convert BSTR to LPCWSTR
本文介绍了将 BSTR 转换为 LPCWSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的需求
BSTR l_strArgs;
LPCWSTR sth;
//----
//---
OutputDebugStringW(sth);
如何将 BSTR 转换为 LPCWSTR?
How to convert BSTR to LPCWSTR ?
是否有任何仅标头的库可以将任何字符串类型(microsoft)转换为 LPCWSTR 类型?
Is there any header only library that coverts any string type(microsoft) to LPCWSTR type ?
推荐答案
只需覆盖 NULL
场景即可
BSTR l_strArgs;
LPCWSTR sth = strArgs ? strArgs : L"";
正如你在标签中提到的 ATL,这里是 ATL 风格的单行:
As you mentioned ATL in the tag, here is ATL-style one-liner:
OutputDebugString(CString(l_strArgs));
或者,为了确保您留在 Unicode 域中:
or, to make sure you are staying in Unicode domain:
OutputDebugStringW(CStringW(l_strArgs));
这篇关于将 BSTR 转换为 LPCWSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文