Interop
-
If I have the C code: beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput); can I just use ...(..., short[] Samples, ...) or do I need pSamples to be an IntPtr? If you want to check out the simple code (a wav -> mp3 encoder) it's located at http://www.geocities.com/grv575/encode.zip I don't see what's wrong besides maybe the gc moving the managed arrays around if that's what causing the encode method to fail.
-
If I have the C code: beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput); can I just use ...(..., short[] Samples, ...) or do I need pSamples to be an IntPtr? If you want to check out the simple code (a wav -> mp3 encoder) it's located at http://www.geocities.com/grv575/encode.zip I don't see what's wrong besides maybe the gc moving the managed arrays around if that's what causing the encode method to fail.
Hi, To pass unknown length arrays as parameters is not allowed in C#. You have to inform the length of it to the function and use something like below, [MarshalAs(UnmanagedType.ByValArray, SizeConst=TheLengthOfArray] ..... your function declaration ( ..., byte [] Samples,.... ) But if the length of the array has not a constant value then you need to find the address of your byte array and then use that address to pass to your function cheers, Doing something is better than doing nothing. So ... Move !