Re: P/invoke an array of structs with embedded char* buffers

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



int CaptureMultiple( CapBuffer ** capBufferArr, unsigned int
numBuffer ..)

Buffer's 1, 2 & 3 are to be preallocated to 20000 bytes, and the dll
will populate these buffers.

I pass the arrray to structs parameter as:

internal static extern int CaptureMultiple( [In, Out] CapBuffer[]
capBufferArr, UInt32 numBuffers...)

Using CapBuffer[] as the parameter type will effectively give you a
CapBuffer* on the native side. You need one more level of indirection
to match the original signature.


[MarshalAs(UnmanagedType.SysUInt)]
public IntPtr Buffer1;

This is what I'd use.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.