VC中CSTRING 转char*,,,转string

来源:互联网 发布:windows核心编程第5版 编辑:程序博客网 时间:2024/06/01 10:29

 

void CMianDlg::CStringToChar(CString strSource, char *chDes)
{
 int nLength = strSource.GetLength();
 int nBytes = WideCharToMultiByte(CP_ACP,0,strSource,nLength,NULL,0,NULL,NULL);
 WideCharToMultiByte(CP_OEMCP, 0, strSource, nLength, chDes, nBytes, NULL, NULL);
}

 

 

CString str, strSqlDel;
 str = m_listCtrl.GetItemText(nIndex, 5);
 str = str.Trim();
 strSqlDel.Format(_T("DELETE FROM  nvr_ipc_table WHERE IPC_IP = '%s'"), str);

 CStringA  stra(strSqlDel.GetBuffer(0));
 std::string  strBuffer = stra.GetBuffer(0);

 

0 0