HID Test Application for Visual Basic .NET

Project: usbhidio_vbdotnet
Version: 2.2
Date: 7/13/05

Purpose:
Demonstrates USB communications with a generic HID-class device

Description:
Finds an attached device that matches the vendor and product IDs in the forms'
text boxes.
Retrieves the device's capabilities.
Sends and requests HID reports.

Uses RegisterDeviceNotification() and WM_DEVICE_CHANGE messages
to detect when a device is attached or removed.
RegisterDeviceNotification doesn't work under Windows 98 (not sure why).

A list box displays the data sent and received,
along with error and status messages.

Combo boxes select data to send, and 1-time or timed, periodic transfers.

You can change the size of the host's Input report buffer and request to use control
transfers only to exchange Input and Output reports.

To view additional debugging messages, in the Visual Studio development environment,
select the Debug build (Build > Configuration Manager > Active Solution Configuration)
and view the Output window (View > Other Windows > Output)

The application uses a Delegate and the BeginInvoke and EndInvoke methods to read
from the device asynchronously.

If you want to only receive data or only send data, comment out the unwanted code
(In ExchangeInputAndOutputReports or ExchangeFeatureReports, comment out
the "Success = " line and the "If Success" block that follows it).

This project includes the following modules:
frmMain.vb - routines specific to the form.
Hid.vb - routines specific to HID communications.
DeviceManagement.vb - routines for obtaining a handle to a device from its GUID
and receiving device notifications. This routines are not specific to HIDs.
Debugging.vb - contains a routine for displaying API error messages.

HidDeclarations.vb - Declarations for API functions used by Hid.vb.
FileIODeclarations.vb - Declarations for file-related API functions.
DeviceManagementDeclarations.vb - Declarations for API functions used by DeviceManagement.vb.
DebuggingDeclarations.vb - Declarations for API functions used by Debugging.vb.

Companion device firmware for several device CPUs is available from www.Lvr.com/hidpage.htm.
You can use any generic HID (not a system mouse or keyboard) that sends and receives reports.

New in version 2.2:
The application obtains separate handles for device information/Feature reports,
Input reports, and Output reports. This enables getting information about
mice and keyboards.
The application detects if the device is a mouse or keyboard
and warns that Windows 2000/XP will not allow exchanging Input or Output reports.
The list box's contents are trimmed periodically.

For more information about HIDs and USB, and additional example device firmware to use
with this application, visit Lakeview Research at http://www.Lvr.com .

Send comments, bug reports, etc. to jan@Lvr.com .

This application has been tested under Windows 98SE, Windows 2000, and Windows XP.