Pass a buffer of chars from .NET to COM and get it back updated
问题 I have the following COM method to be called from C#, which returns a string in the provided buffer pchText (which is not necessarily zero terminated) and the number of characters copied in pcch : HRESULT Next([in, out] long* pcch, [out, size_is(*pcch)] OLECHAR* pchText); How do I define the C# signature for interop? So far, I tried this: void Next(ref int pcch, [MarshalAs(UnmanagedType.LPWStr, SizeParamIndex = 0)] System.Text.StringBuilder pchText); It appears to work, but I am not sure if