网络摄像头在c锐器中检测 [英] Webcam Detect in c sharp

查看:68
本文介绍了网络摄像头在c锐器中检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#在本地系统中检测网络摄像头.

请发送代码而不使用其他dll,而仅使用Windows组件?

Webcam detect in local system using C#.

Please send the code without using other dll and only using windows component?

推荐答案

使用本文:

这就是我使用的:)
还记得将System.Management添加到项目的引用中

好的,这是.NET版本
This is what I use :)
Also remember to add System.Management to the project''s references

OK here is .NET version
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


这是C#版本


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;
	}
}


这将获取网络摄像头的名称.您还可以将第三行到最后一行的设备名称"更改为很多内容.只需进行一个小的Google搜索!
祝你好运


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


试试这个

使用DirectShow.NET的网络摄像头 [检测网络摄像头 [
Try this

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

BTW convert the code into C# :)


这篇关于网络摄像头在c锐器中检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆