CAD工具之家's Archivers

From boitboy on 2013-08-27 17:44:34

宽字节转换为单字节

//使用过后必须释放 char* ConvertToLPCSTR(CString swString) { #ifdef _UNICODE char* szBuf = NULL; UINT nLen = NULL; nLen = WideCharToMultiByte(CP_ACP, 0, swString/*wszString*/, -1, NULL, 0, NULL, NULL); szBuf = (char*)malloc(nLen + 1); int nRet = WideCharToMultiByte(CP_ACP, 0, swString, -1, szBuf, nLen, NULL, NULL); if (0 == nRet) { free(szBuf); szBuf = NULL; } return szBuf; #else char* szBuf = NULL; int nLen=swString.GetLength()+1; szBuf = (char*)malloc(nLen + 1); strcpy(szBuf,swString); return szBuf; #endif } 注意:使用过后必须使用free释放

查看完整版本: 宽字节转换为单字节

Tags:


©CAD工具之家
创办于:2013年5月24日