MFC 编程时常遇到的一个问题,在网上找到了这样的代码,修改了下。
LPWSTR ConvertLPCSTRToLPWSTR (const char* pCstring)
{
LPWSTR pszOut = NULL;
if (pCstring != NULL)
{
int nInputStrLen = strlen (pCstring);
int nOutputStrLen = MultiByteToWideChar(CP_ACP, 0, pCstring, nInputStrLen, NULL, 0) + 2;
pszOut = new WCHAR [nOutputStrLen];
if (pszOut)
{
memset (pszOut, 0x00, sizeof (WCHAR)*nOutputStrLen);
MultiByteToWideChar (CP_ACP, 0, pCstring, nInputStrLen, pszOut, nInputStrLen);
}
}
return pszOut;
}
发表于 @ 2009年05月13日 21:34:00 | 评论( loading... ) | 举报| 收藏