Assuming that you have a std::string
on hand, which is vaguely indicated by your question, and assuming further that you're building a Unicode app, also vaguely indicated, then you can probably do
CString mfc_string( s.c_str() );
// Use mfc_string here.
where s
is the std::string
.
The CString
constructors are documented in MSDN Library.
It's often a good idea to consult the documentation.
Background: LPCTSTR
is a macro that expands to either char const*
or wchar_t const*
depending on whether the symbol UNICODE
was defined when <windows.h>
was included. It's a compatibility thing, for writing code that might work, with some drastically reduced functionality and reliability, in Windows 9x. Unless you're targeting Windows 9x, forget it, don't use the T
macro stuff.
The T
macros became obsolete already in the year 2000, when Microsoft introduced the Layer for Unicode which lets Unicode apps work in Windows 9x (with only slightly reduced functionality).
That they're still used for non-legacy code in 2014, long after the demise of the target platform, is, IMHO, a testimony to the extreme power and self-sustainability of conformity.