473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

API interfacing with a LPBYTE from C#

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
2 9005
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: 2mc | last post by:
All, I'm getting a better handle on Python and NumPy. I've found solutions to many of my questions. Thanks to all. I would like to interface Python (in WinXP) with another program through...
4
by: Chuck Amadi | last post by:
Hi all Anyone know a good Pygresql Tutorial for Interfacing between Python & Postgresql . Cheers Chuck
12
by: David Walker | last post by:
Hi I have a program which I need to interface with a webpage - the webpage will accept an input (probably a 'post' string from the program) and then will process it and needs to return a value. ...
4
by: Shaurya Anand | last post by:
I would like to know more about Interfacing hardware devices through .NET. We're students and what we're trying to do is control our robots with printer or serial port interfacing... very similar...
3
by: Kevin | last post by:
Hi All I got some good responses from some of you guys regarding me serial port interfacing problem that I posted a little while back. However your help leaded me to this link belo ...
2
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
2
by: Dave A | last post by:
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 ...
0
by: donix | last post by:
Hi, I am trying to convert a LPBYTE array to a character array.... Any suggestions on how this can be done....
1
by: Nandhini123 | last post by:
hi In VC++ how to use LPBYTE. i want to use inside structure,so dynamically i wil get n bytes value. i want to get a value from structure.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.