In your C++ DLL:
__declspec(dllexport) TCHAR* __cdecl testString();
__declspec(dllexport) TCHAR* testString()
{
return _T("Wheee!");
}
And to call it from your C# you need to do something like:
class Program
{
[DllImport("MyDLL.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr testString();
void CallCppDLL()
{
IntPtr t = testString();
String result = Marshal.PtrToStringAuto(t);
}
}
I haven't done this in quite some time, so feel free to correct me :)