这篇KB 有点儿老,是针对Visual C++.NET 7.1 的。 如果你使用的是Visual Studio 2005/2008 请参考下面代码:
using namespace System::Runtime::InteropServices;
System::String^ str = L"Hello world";
char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(str);
……
Marshal::FreeHGlobal(str2);