473,545 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

API interfacing with a LPBYTE from C#

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

HRESULT CamPreviewGetBG R16(HANDLE hCamera,LPBYTE pBuffer);

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

[DllImport("mobi lecamapi.dll",E ntryPoint="CamP reviewGetBGR16" )]
public static extern int CamPreviewGetBG R16(uint hCamera, byte[] pBuffer);

and have called it via:

byte[] buffer = new byte[width * height * 2];
result = CamPreviewGetBG R16(cameraHandl e, 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 9021
Dug around a bit for lpbyte and C# and found some information on it...

System.Runtime. InteropServices .Marshal.CopyBy tesToManaged(In t32 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 CamPreviewGetBG R16(HANDLE hCamera,LPBYTE pBuffer);

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

[DllImport("mobi lecamapi.dll",E ntryPoint="CamP reviewGetBGR16" )]
public static extern int CamPreviewGetBG R16(uint hCamera, byte[] pBuffer);

and have called it via:

byte[] buffer = new byte[width * height * 2];
result = CamPreviewGetBG R16(cameraHandl e, 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*******@disc ussions.microso ft.com> wrote in message
news:11******** *************** ***********@mic rosoft.com...
Dug around a bit for lpbyte and C# and found some information on it...

System.Runtime. InteropServices .Marshal.CopyBy tesToManaged(In t32 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 CamPreviewGetBG R16(HANDLE hCamera,LPBYTE pBuffer);

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

[DllImport("mobi lecamapi.dll",E ntryPoint="CamP reviewGetBGR16" )]
public static extern int CamPreviewGetBG R16(uint hCamera, byte[] pBuffer);
and have called it via:

byte[] buffer = new byte[width * height * 2];
result = CamPreviewGetBG R16(cameraHandl e, 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
1314
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 the COM object. This other program downloads data for me on a daily basis. I have a choice of many methods to export the data from this program -...
4
5802
by: Chuck Amadi | last post by:
Hi all Anyone know a good Pygresql Tutorial for Interfacing between Python & Postgresql . Cheers Chuck
12
2694
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. Is there an easy way to interface the program to do this? I have two questions: How can I call a webpage as simply as possible in c / c++...
4
1852
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 to C++ classic style. Please help us as it could do great wonders for our project.
3
1929
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 http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=9dde5cf3-4842-4d4b-baa7-73e09c4d589 Now my questions is - forgive me because I am still...
2
2203
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 access the database layer. However, the code works in a pretty cumbersome and ungeneric way. Basically every query, update, and insert has its own ...
2
364
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 public static extern int CamPreviewGetBGR16(uint hCamera, byte pBuffer); and have called it via:
0
3675
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
2932
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
7468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7757
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.