7,539
社区成员
发帖
与我相关
我的任务
分享#include <windows.h>
#include <atlstr.h>
#define STRSAFE_NO_DEPRECATE
#include <strsafe.h> // for String... functions
#include <crtdbg.h> // for _ASSERTE
CStringW ConvertW(CString str, int sourceCodepage)
{
//int len=str.GetLength();
int unicodeLen=MultiByteToWideChar(sourceCodepage,0,str,-1,NULL,0) + 1;
wchar_t* pUnicode;
pUnicode=new wchar_t[unicodeLen];
memset(pUnicode,0,(unicodeLen)*sizeof(wchar_t));
MultiByteToWideChar(sourceCodepage, CP_ACP, str, -1, (LPWSTR)pUnicode, unicodeLen);
CStringW rt = pUnicode;
//delete pUnicode;
SAFE_DELETEGROUP( pUnicode );
return rt;
} CStringW wszTemp = ConvertW( Filename, CP_ACP);
LPWSTR pwStr = wszTemp.GetBuffer();