vc ++ - 如何将CString转换为LPCWSTR [英] vc++ - How to convert a CString into LPCWSTR

查看:196
本文介绍了vc ++ - 如何将CString转换为LPCWSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图这样做,但我没有找到任何方法。我问这是因为我是新的Windows。我试过stl字符串,但visual studio 2008-累积在stl-wstring处理的bug。我会在以后再说很多关于其他问题。

I tried to do this , but I didn't find any method for this. I am asking this due to the fact that I am new to windows. I tried stl-strings, but visual studio 2008- accumulates bugs in stl-wstring-handling. I will say a lot about that thing later, in other question. Now Can anybody shed light on this issue?

推荐答案

使用类似这样的转换类CT2CW FuncTakingLPCWSTR(CT2CW (cstring_var))。这保证在Unicode或MBCS构建中工作。

Use the conversion class CT2CW like this FuncTakingLPCWSTR(CT2CW(cstring_var)). This is guaranteed to work in either Unicode or MBCS builds.

另外,请记住传递给函数的字符串可能是临时的,因此不要存储它供以后使用。

Also, keep in mind that the string passed to the function may be a temporary, so don't store it for later use.

这篇关于vc ++ - 如何将CString转换为LPCWSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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