I can't seem to find any information on forcing a callback from a C++ dll to C# to use Unicode strings. I use a StringBuilder type for the function prototype but it doesn't seem to know it's a PWCHAR that is being returned. Is there any way to explicity tell it to expect a Unicode string?
Here is the callback type in C++
typedef int (__stdcall *WMP_ERROR)(long ErrorCode, PWCHAR ErrorDesc);
and here it is defined in C#
public delegate void WMP_ERROR(uint ErrorCode, StringBuilder ErrorDesc);
[MarshalAs(UnmanagedType.FunctionPtr)]
WMP_ERROR pError = null;
When I output ErrorDesc.ToString() it will only print the first letter of the string (as it would if it expects an Ansi string.