vc++ Unicode Cstring to char*

BOOL CRDlg::WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize)
{
 DWORD dwMinSize;
 dwMinSize = WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,NULL,0,NULL,FALSE);
 if(dwSize+1 < dwMinSize)
 {
  	return FALSE;
 }
 WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,lpszStr,dwSize,NULL,FALSE);
 return TRUE;
}
 
CString csSum = T("count");
char cCountSum[15];
memset(cCountSum,0,sizeof(cCountSum));
WCharToMByte(csSum,(LPSTR)cCountSum,sizeof(cCountSum)/sizeof(cCountSum[0]));


 

 

 

阅读更多
文章标签: vc++ null
个人分类: VC
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭