Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Webcam detect in local system using C#.

Please send the code without using other dll and only using windows component?
Posted
Updated 6-Nov-11 4:48am
v2

Use this article : Versatile WebCam C# library[^]
 
Share this answer
 
Comments
[no name] 6-Nov-11 10:14am    
He was asking for detection not capturing.
Mehdi Gholam 6-Nov-11 10:32am    
Detection is done by windows automatically.
This is what I use :)
Also remember to add System.Management to the project's references

OK here is .NET version
VB
Dim info As System.Management.ManagementObject
           Dim search As System.Management.ManagementObjectSearcher
           Dim deviceName As String
           search = New System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity")
           For Each info In search.Get()
               deviceName = CType(info("Caption"), String)
               If InStr(deviceName, "cam", CompareMethod.Text) > 0 Then
                   GetSystemInfo.Webcam = deviceName
               End If
           Next

Here is C# version
System.Management.ManagementObject info = default(System.Management.ManagementObject);
System.Management.ManagementObjectSearcher search = default(System.Management.ManagementObjectSearcher);
string deviceName = null;
search = new System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity");
foreach ( info in search.Get()) {
	deviceName = Convert.ToString(info("Caption"));
	if (Strings.InStr(deviceName, "cam", CompareMethod.Text) > 0) {
		GetSystemInfo.Webcam = deviceName;
	}
}

This gets the name of the webcam. You can also change "device name" in the third to last line to a lot of things. Just make a small Google search!
Good luck
 
Share this answer
 
v3
Try this

Webcam using DirectShow.NET[^]
Also check this thread Detect Webcam[^]

BTW convert the code into C# :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900