char* 转换成 LPCTSTR
char ch[1024] = "xxxx"; int num = MultiByteToWideChar(0,0,ch,-1,NULL,0); wchar_t *wide = new wchar_t[num]; MultiByteToWideChar(0,0,ch,-1,wide,num);
LPCTSTR 转换成 char *
wchar_t widestr[1024] = L"xxxx"; int num = WideCharToMultiByte(CP_OEMCP,NULL,widestr,-1,NULL,0,NULL,FALSE); char *pchar = new char[num]; WideCharToMultiByte (CP_OEMCP,NULL,widestr,-1,pchar,num,NULL,FALSE);
如果是一个路径里面有//,有的时候需要替换为
#include <afxpriv.h> CString subfile1 = subfile.Left(subfile.ReverseFind('.')); subfile1.Replace('\','/'); USES_CONVERSION; m_db->UpDataPicDir((char*)T2A(subfile1), backid);
char* 转CString
char* pData = "1234"; CString strData(pData);
关于字符串处理的文章
https://blog.csdn.net/GoForwardToStep/article/details/53079967
宽字符的拼接
TCHAR buf[255];
wsprintf(buf, _T("RegisterUploadMinFile %s ok!
"), A2T(strFileName.c_str()));
CString强转int
mORDERINFO.back_id= _ttoi(CString((*p)["back_id"].asString().c_str()));