将BSTR转换为LPCWSTR [英] convert BSTR to LPCWSTR

查看:141
本文介绍了将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场景,您就可以开始使用

Just cover NULL scenario and you're good to go

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆