Click here to Skip to main content
15,744,010 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My app is running in kiosk machine and it connect with multiple devices as printer, camera, weighing scale, barcode scanner etc through USB port.
It will check the connection of device when selected any port. Currently, I only can check which port is connected but can't identify which device it is.

What I have tried:

As the picture below there are 2 devices and they are connected to kiosk. If I select 'USB Input Device' port for touch screen and select another port for printer. How I do to check exactly 'USB Input Device' port is touch screen connected but not printer. In case 'USB Input Device' port is printer, app will be display message.[^]
Updated 2-Feb-23 0:24am

1 solution

Using C# you can query the PnP devices on the system by running:
using (var search = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity Where DeviceID Like ""USB%"""))
    using (var collection = search.Get())
        foreach (var device in collection)
            Console.WriteLine($"Device ${device.GetPropertyValue("DeviceID")}:");

            foreach (var prop in device.Properties)
                Console.WriteLine($"- ${prop.Name} = ${prop.Value}");

One of these properties is Name which generally gives a slightly more helpful identifier for the device. It's not perfect though but it could give a good starting point if you're producing dropdown lists that someone can select.
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