Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用C检测连接到我的机器的摄像头#_C#_Winapi_Camera - Fatal编程技术网

C# 如何使用C检测连接到我的机器的摄像头#

C# 如何使用C检测连接到我的机器的摄像头#,c#,winapi,camera,C#,Winapi,Camera,我能够知道连接到电脑的声音设备和USB设备,但无法找到连接到电脑的摄像头。 下面的代码用于获取声音设备 Console.WriteLine("Win32 SoundDevices\r\n==============================="); ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from Win32_SoundDevice");

我能够知道连接到电脑的声音设备和USB设备,但无法找到连接到电脑的摄像头。 下面的代码用于获取声音设备

Console.WriteLine("Win32 SoundDevices\r\n===============================");
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from Win32_SoundDevice");
            foreach (ManagementObject soundDevice in searcher.Get())
            {
                //Console.WriteLine("Device found: {0}\n", soundDevice.ToString());
                Console.WriteLine("Device found: {0}\n", soundDevice.GetPropertyValue("ProductName"));
            }
            Console.WriteLine("Search complete.");

该工具将证明有帮助:

我相当肯定,对于网络摄像头,没有专门发送到
ManagementObjectSearcher()
的等效字符串。有一个“Win32_USBControllerDevice”,您可以确定它是否是网络摄像头

一个更好的解决办法是充分利用