|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DLL Callbackdeligate and all imformation is correct except for an array. This is the original struct in c: typedef void (*PutSampProc)(short samples[], int arraylen, int nrsamples,void *userData); This does not work: <StructLayout(LayoutKind.Sequential)> _ Public Structure PutSampProc2 <MarshalAs(UnmanagedType.ByValArray,SizeConst:=1024)> _ Dim Samples() As Short Dim ArrayLen As Integer Dim NrSamples As Integer Dim Userdata As Byte End Structure This gives the correct data for ArrayLen, NrSamples and Userdata, but just a value for the Samples(): <StructLayout(LayoutKind.Sequential)> _ Public Structure PutSampProc Dim Samples As Integer Dim ArrayLen As Integer Dim NrSamples As Integer Dim Userdata As Byte End Structure What am I doing wrong???? Please help Nigel *** Sent via Developersdex http://www.developersdex.com *** Nigel,
>This is the original struct in c: This is not a struct declaration, it's a function pointer type.> >typedef void (*PutSampProc)(short samples[], int arraylen, int >nrsamples,void *userData); Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. I now have it working like this:
Private Sub SampProc(ByVal Samples As Integer, ByVal ArrayLen As Integer, ByVal NrSamples As Integer, ByVal UserData As Byte) ReDim MySamples((NrSamples * 2) - 1) Marshal.Copy(Samples, MySamples, 0, NrSamples * 2) Is it possible to receive 'Samples' as an array. Do I have to add some marshalling code to my delegate? Nigel *** Sent via Developersdex http://www.developersdex.com *** |
|||||||||||||||||||||||