I would like to Read the name of USB camera (i.e., HD USB camera) attached to Windows 10 and store the name as a variable in C#.
Asked
Active
Viewed 1,346 times
1 Answers
2
You can try to filter the items in the Win32_PnPEntity
class to only show items referring to the IMAGE or MEDIA category, which usually list items referring to the webcam connected to usb.
In the SQL command you can change the category.
using System.Management;
private static void GetUSBDevices()
{
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PnPEntity WHERE (PNPClass = 'Image' OR PNPClass = 'Camera')");
foreach (var device in searcher.Get())
{
Console.WriteLine($"Device: {device["PNPClass"]} / {device["Caption"]}");
}
}
You will need to add the System.Management dependency to the project.

Alberto Santos
- 357
- 1
- 9
-
I changed the "Win32_PnPSignedDriver" library to "Win32_PnPEntity" that best suits what you asked. – Alberto Santos Feb 28 '19 at 02:41