public :void foo()
{
LPCWSTR bar = stringToLPCWSTR(gcnew String("xddd"));
std::wcout << bar; //prints nothing
}
LPCWSTR stringToLPCWSTR(String^ s) {
msclr::interop::marshal_context context;
std::string ss = context.marshal_as<std::string>(s);
std::wstring ws;
ws.assign(ss.begin(), ss.end());
LPCWSTR pcwstr = ws.c_str();
std::wcout << pcwstr; //works
return pcwstr;
}
我需要将C#号插座转换为LPCWSTR hovewer分配值脱粒机。 我怎么能够使问题持续下去?