free hit counter Webcam in your own applications using C# - Nauman Leghari's Blog
Monday, March 13, 2006 6:51 PM laghari78

Webcam in your own applications using C#

I recently worked on another project where I wanted to use the Webcam. As part of that, I looked for the resources and found a couple of different ways of doing this.

1) Using WIA SDK:

This is the easier of the two methods to control the webcam by using the COM wrapper. This COM API is provided as part of the WIA SDK. Although most of the webcams do work by this method but if you get an exception "Exception from HRESULT: Ox80210015", chances are that you can't use this API.
Otherwise, this is a much better option. For more information, check Scott's article on MSDN.

2) Using "avicap32.dll":

The second method is to invoke the API's inside "avicap32.dll" to interact with the webcam device. This is a bit harder as you have to manually create signatures for the methods inside the dll.

So, for this project I wrote a simple class to wrap the basic functionality exposed by the dll. By using that, you will be able to get all the attached devices and can also see the preview of webcam inside a control (such as picturebox). It is a very small project but will save someone a little time.

Download Source Code and Sample Project

There are two projects inside the zip file.

WebCamLib: This contains the wrapper around a couple of API's in "avicap32.dll".
Qurtaba: A Test project which uses the WebCamLib to show webcam preview.

Filed under: , , ,


# re: Webcam in your own applications using C#

Tuesday, March 14, 2006 4:13 AM by Mihir Solanki

Thanks for sharing the source code ...

# re: Webcam in your own applications using C#

Tuesday, March 28, 2006 5:51 AM by R'vin

and how to use WebCamLib