Click here to Skip to main content
Click here to Skip to main content

A USB HID Component for C#

, 22 Mar 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
A component to communicate with a USB HID device


This article is about a USB HID component which enables you to communicate with HID devices over USB. There is no default component available for USB at this moment, and this component should provide you with a good starting point when writing your own USB HID enabled applications.

This article provides a sample application as well as the component itself.


The component is based on various sources. A good start for USB in C# is this website. Also the book USB COMPLETE (third edition) by Jan Axelson is a must read for anyone wishing to incorporate USB HID into her/his application.

The component is developed during a project at the Avans Hogeschool in 's-Hertogenbosch, The Netherlands.

Using the Code

In the provided sample application, there is a good demonstration on how to include the component. Moreover, the use of the component is very well demonstrated. The only thing that must be done in your own application is implementing the events.

You'll also have to override the following functions in your form, so that your program is USB aware. In the property box, you'll have to provide a vendor and product id of your USB device in order to detect the correct device.

protected override void OnHandleCreated(EventArgs e)
protected override void WndProc(ref Messagea m)
usb.ParseMessages(ref m);
base.WndProc(ref m); // pass message on to base form

Points of Interest

A mouse is always in use by Windows, and cannot be captured by your own application. This also applies to HID devices in use by other applications.


  • 22nd March, 2007: First version, currently in development

Updates will be posted if there is a need for them.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Netherlands Netherlands
No Biography provided

Comments and Discussions

QuestionReading from USB device PinmemberMember 1084745313-Feb-15 13:03 
AnswerRe: Reading from USB device PinmemberMember 1084745314-Feb-15 13:12 
QuestionSpecifiedDevice Pinmemberjeremystein123414-Jan-15 11:27 
QuestionHow to write data in USB HID device? PinmemberMember 112767143-Dec-14 20:46 
QuestionHow to support more than one device with similar PID and VID and different serial Pinmemberelekgeek1-Dec-14 21:36 
QuestionSerial Number of HID device Pinmemberelekgeek30-Nov-14 1:03 
AnswerRe: Serial Number of HID device [modified] PinmemberGarth J Lancaster30-Nov-14 1:31 
GeneralRe: Serial Number of HID device Pinmemberelekgeek30-Nov-14 4:10 
GeneralRe: Serial Number of HID device PinmemberGarth J Lancaster30-Nov-14 11:09 
GeneralRe: Serial Number of HID device [modified] Pinmemberelekgeek30-Nov-14 21:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 22 Mar 2007
Article Copyright 2007 by wimar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid