void Wide2Bytes(char* pBytes,TCHAR* pWide)
{
int nLen = WideCharToMultiByte(CP_ACP,0,pWide,-1,NULL,0,NULL,NULL);
// get need convert length
int i = (int)wcslen(pWide)*sizeof(TCHAR);
// get need new memory size
pBytes = new char[i+1];
if (!pBytes) // if fail then new again
{
pBytes = new char[i+1];
}
if(!pBytes) { return; }
WideCharToMultiByte(CP_ACP,0,pWide,-1,pBytes,nLen,NULL,NULL);
}
评论