C++ CLI System.String^ to MFC LPCTSTR

后端 未结 2 607
青春惊慌失措
青春惊慌失措 2021-02-14 09:39

How would I convert a System (.net) C++\\CLI String^ into a MFC C++ LPCTSTR string.

It is very easy to get a LPCTSTR

2条回答
  •  无人共我
    2021-02-14 10:17

    You might want to try Marshal::StringToHGlobalUni, Marshal::StringToHGlobalAuto or Marshal::StringToHGlobalAnsi.

    Remember the allocated unmanaged strings will need to be freed with Marshal::FreeHGlobal.

提交回复
热议问题