You can handle a reference to a pointer pretty much like a pointer to a pointer, at least as far as P/Invoke is concerned.
I think you will probably need to use an IntPtr
for the sResult
parameter, along with either Marshal.PtrToStringAnsi()
or Marshal.PtrToStringAuto()
, but it's a bit difficult to say without knowing whether the C/C++ function allocates the string memory or not.
If it works, you will probably still need to free the memory (after getting the string) using Marshal.FreeCoTaskMem()
or Marshal.FreeHGlobal()
, but again this is impossible to know for sure without knowing what the C/C++ function does.
NOTE: If using an IntPtr
to get an output value, you will need to use out result
or ref result
.