API interfacing with a LPBYTE from C#

D

Dave A

Hi, I have the following function that I need to call from C#.

HRESULT CamPreviewGetBGR16(HANDLE hCamera,LPBYTE pBuffer);

but I am stuggling with the LPBYTE pBuffer. I have decalred it as

[DllImport("mobilecamapi.dll",EntryPoint="CamPreviewGetBGR16")]
public static extern int CamPreviewGetBGR16(uint hCamera, byte[] pBuffer);

and have called it via:

byte[] buffer = new byte[width * height * 2];
result = CamPreviewGetBGR16(cameraHandle, buffer);

It is returning with a missing method exception. I think the 'byte[]
pBuffer' in the API definition needs to be a 'uint pBuffer' but then how do
I convert the 'byte[] buffer' in the calling code to be a uint? (I am a bit
of a novice at all of this Interop stuff)

Any suggestions are greatly appreaciated.

Thanks

Dave A
 
G

Guest

Dug around a bit for lpbyte and C# and found some information on it...

System.Runtime.InteropServices.Marshal.CopyBytesToManaged(Int32 source,
Byte[] destination, Int32 startIndex, Int32 length)

Not sure but it looks to be what will make you a managed lpbyte array, also
if you have too much trouble with this dll, there's avicap32.dll that I
always used to do webcam things with.
 
D

Dave A

Thanks! That looks like the answer.

This is for the Pocket PC. I don't think avicap32.dll will work.

Regards
Dave

Xedecimal said:
Dug around a bit for lpbyte and C# and found some information on it...

System.Runtime.InteropServices.Marshal.CopyBytesToManaged(Int32 source,
Byte[] destination, Int32 startIndex, Int32 length)

Not sure but it looks to be what will make you a managed lpbyte array, also
if you have too much trouble with this dll, there's avicap32.dll that I
always used to do webcam things with.

Dave A said:
Hi, I have the following function that I need to call from C#.

HRESULT CamPreviewGetBGR16(HANDLE hCamera,LPBYTE pBuffer);

but I am stuggling with the LPBYTE pBuffer. I have decalred it as

[DllImport("mobilecamapi.dll",EntryPoint="CamPreviewGetBGR16")]
public static extern int CamPreviewGetBGR16(uint hCamera, byte[] pBuffer);

and have called it via:

byte[] buffer = new byte[width * height * 2];
result = CamPreviewGetBGR16(cameraHandle, buffer);

It is returning with a missing method exception. I think the 'byte[]
pBuffer' in the API definition needs to be a 'uint pBuffer' but then how do
I convert the 'byte[] buffer' in the calling code to be a uint? (I am a bit
of a novice at all of this Interop stuff)

Any suggestions are greatly appreaciated.

Thanks

Dave A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top