How to Convert string to LPCTSTR ?

Convert string to LPCTSTR ...
This is a problem that I have encountered many times in coding, especially when code with the MFC. I try to find on Internet but have some way to complex for a small problem.
Finally, I and my friend found out a simple way but very effective.


LPCTSTR ConvertFromString (string strVar)
{
      // Convert string to CString
      CString tmp(strVar.c_str());
      // Use CString like LPCTSTR
      return tmp;
}

Your Reply