Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scanning for a Human Interface Device (HID) using C#

I am developing a C# .NET 2.0 application wherein I need to scan for an attached HID. How can this be done? Because it is a HID, Windows does not assign a COM port to it. I only need to programmatically determine if the device is attached. Thank you.

ADDITIONAL INFORMATION

When I connect the USB device to my computer two entries appear under Human Interface Devices in the Device Manager. Clicking into their Properties yields this information in their respective Details tabs:

HID-compliant device Device Instance Id: HID\VID_1795&PID_6004\7&2694D932&0&0000

USB Human Interface Device Device Instance Id: USB\VID_1795&PID_6004\B973000000EB0D00

like image 853
Jim Fell Avatar asked Sep 16 '10 19:09

Jim Fell


People also ask

Which is an example of a human interface device HID )?

An HID takes input from or provides output to humans. Examples of devices include keyboards, pointing devices (mice, touchscreens, etc.), and gamepads. The HID protocol makes it possible to access these devices on desktop computers using operating system drivers.

How do you fix a human interface device?

On your keyboard, press the Windows logo key and type troubleshoot, then click Troubleshoot. Locate and click on Hardware and Devices and click Run the troubleshooter. Click Next and follow the on-screen instructions to fix the issues it detects.

What is human interface device?

What Does Human Interface Device (HID) Mean? A human interface device (HID) is a method by which a human interacts with an electronic information system either by inputting data or providing output. A myriad of HID devices exist. The most common are the keyboards, mice, computer speakers, webcams and headsets.

How do HID devices work?

The device is the entity that directly interacts with a human, such as a keyboard or mouse. The host communicates with the device and receives input data from the device on actions performed by the human. Output data flows from the host to the device and then to the human.


1 Answers

In the WMI Code Creator select these options:

Namespace: root\WMI

Class: MSWmi_PnPInstanceNames

Select InstanceNames from the Results box for the following code:

using System;
using System.Management;
using System.Windows.Forms;

namespace WMISample
{
    public class MyWMIQuery
    {
        public static void Main()
        {
            try
            {
                ManagementObjectSearcher searcher = 
                    new ManagementObjectSearcher("root\\WMI", 
                    "SELECT * FROM MSWmi_PnPInstanceNames"); 

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("MSWmi_PnPInstanceNames instance");
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);
                }
            }
            catch (ManagementException e)
            {
                MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
            }
        }
    }
}
like image 66
Jim Fell Avatar answered Sep 20 '22 01:09

Jim Fell