CString 转化成 const char*


CString yourString = . . .;

CStringA ansiString(yourString);

此时 ansiString可以作为const char*型调用

CString str;

const char* cstr = (LPCTSTR)str;

CString str;

const TCHAR* cstr = (LPCTSTR)str;

//将LPCTSTR转换成const char*型。因为在宽字符系统里 LPCTSTR = const TCHAR*  char *pTempPath;

  LPCTSTR lpszPathName;
  int lenPath =  WideCharToMultiByte(CP_OEMCP,NULL,lpszPathName,-1,NULL,0,NULL,FALSE);  //需要的字符长度
  pTempPath = new char[lenPath];
  WideCharToMultiByte (CP_OEMCP,NULL,lpszPathName,-1,pTempPath,lenPath,NULL,FALSE);   //转化字符

posted @ 2011-06-16 10:22  flyblue  阅读(900)  评论(0编辑  收藏  举报