private void btnTest_Click(object sender, System.EventArgs e)
        {
            //Make sure the DirectInput 8 Device Instance is empty.
            if (DIDI8 != null)
            {
                DIDI8 = null;
            }

            //Get the device information.
            CreateInputDeviceInstance("Mouse");

            //Display the status information.
            if ((DIDI8.GetDevType() & (UInt32)CONST_DI8DEVICESUBTYPE.DIDEVTYPE_HID)
                == (UInt32)CONST_DI8DEVICESUBTYPE.DIDEVTYPE_HID)
            {
                MessageBox.Show("Mouse is a HID");
            }
            else
            {
                MessageBox.Show("Mouse is not a HID");
            }
        }
        private void CreateInputDeviceInstance(String DeviceName)
        {
            DirectInputEnumDevices8    Devs;    //DirectInput device enumeration.
            DirectInputDeviceInstance8 DevInst; //A single device instance.
            Int32 Counter;                      //Loop counter

            //Create a list of devices for this machine.
            Devs = DI8.GetDIDevices(CONST_DI8DEVICETYPE.DI8DEVCLASS_ALL,
                                    CONST_DIENUMDEVICESFLAGS.DIEDFL_ATTACHEDONLY);

            //Search for the correct GUID. Remember to start the
            //Counter at 1 for VB.
            for (Counter = 1; Counter <= Devs.GetCount(); Counter++)
            {
                //Get a device instance.
                DevInst = Devs.GetItem(Counter);

                if (DevInst.GetProductName().ToUpper() == DeviceName.ToUpper())
                {
                    DIDI8 = DevInst;
                    break;
                }
            }
        }