By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

API interfacing with a LPBYTE from C#

P: n/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="CamPrevie wGetBGR16")]
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

Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Dug around a bit for lpbyte and C# and found some information on it...

System.Runtime.InteropServices.Marshal.CopyBytesTo Managed(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" wrote:
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="CamPrevie wGetBGR16")]
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

Jul 21 '05 #2

P: n/a
Thanks! That looks like the answer.

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

Regards
Dave

"Xedecimal" <Xe*******@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
Dug around a bit for lpbyte and C# and found some information on it...

System.Runtime.InteropServices.Marshal.CopyBytesTo Managed(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" wrote:
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="CamPrevie wGetBGR16")]
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

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.