char*(LPSTR)与wchar_t*(LPTSTR) 相互转换的函数

void CharToWchar(const char *constCharString, TCHAR *outWchar) 
{
int   nLen = strlen(constCharString) + 1;   
int   nwLen = MultiByteToWideChar(CP_ACP, 0, constCharString, nLen, NULL, 0);  
    
TCHAR   *wString;
wString = new TCHAR[nwLen];


MultiByteToWideChar(CP_ACP, 0, constCharString, nLen, wString,nwLen);
_tcscpy(outWchar,wString);//   wcscpy(outWchar,wString);


delete[] wString;
}
void WCharToChar(TCHAR *InWchar , char *OutStr)
{
  DWORD dwNum=WideCharToMultiByte(CP_OEMCP,NULL,InWchar,-1,NULL,0,NULL,FALSE)+1;
  WideCharToMultiByte(CP_OEMCP,NULL,InWchar,wcslen(InWchar),OutStr,dwNum,NULL,FALSE);
}

你可能感兴趣的:(null,delete,Class,buffer,编译器)