Quote from:
http://vctipsplusplus.wordpress.com/2008/05/21/cstring-to-tchar/
CString is a very useful MFC class for string management. But, sometimes we want to convert CString data to TCHAR or something.
here is one small code snippet for performing this operation.
CString csData(_T(“”)); LPTSTR szData = csData.GetBuffer(); csData.ReleaseBuffer();
or like this
CString csTemp( "Sample data" ); LPTSTR lpszData = new TCHAR[csTemp.GetLength()+1]; _tcscpy(lpszData , csTemp); delete[] lpszData;// don't forget to do this.