如何在VC ++中将char *转换为LPWSTR? [英] How to Convert char* to LPWSTR in VC++?
本文介绍了如何在VC ++中将char *转换为LPWSTR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在VC ++中将char *转换为LPWSTR?
How to Convert char* to LPWSTR in VC++ ?
LPNETRESOURCEW nr = NULL;
memset(&nr, 0, sizeof (NETRESOURCE));
nr->lpLocalName = strDriveLetter.GetBuffer(strDriveLetter.GetLength()); // this line giving me error "Cannot Convert char* to LPWSTR"
感谢您的帮助. 谢谢.
Any help is appreciated. Thanks.
推荐答案
Use MultiByteToWideChar
function;
const char* msg = "foobarbaz";
int len = strlen(msg) + 1;
wchar_t *w_msg = new wchar_t[len];
memset(w_msg, 0, len);
MultiByteToWideChar(CP_ACP, NULL, msg, -1, w_msg, len);
这篇关于如何在VC ++中将char *转换为LPWSTR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文