Converting from managed String to MFC CString
I have a managed app calling a C++ managed wrapper for a section of unmanaged C++ code which takes type CString as arguments.
When trying to convert from String to CString using a variety of methods the code keeps breaking on the following construct:
const __wchar_t __pin * strProduct2 = PtrToStringChars(strProduct);
CString strProduct3 = CString(strProduct2 );
Stepping in with the debugger leads to the line:
CStringData* pData = pStringMgr->GetNilString();
where the code breaks.
How does one convert a managed String into an unmanaged MFC/ATL 3.0 CString type?
Dirk Neethling
|