原创  wchar 转 char 收藏

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... ) | 编辑| 举报| 收藏

旧一篇:初识c#--菜单栏 | 新一篇: 【转】VS2005无法启动调试的解决方案

  • 发表评论
  • 评论内容:
  •  
Copyright © J_Factory
Powered by CSDN Blog