拙网论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 162|回复: 0

A USB HID Component for C#

[复制链接]

949

主题

1001

帖子

3736

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3736
发表于 2020-4-1 14:06:17 | 显示全部楼层 |阅读模式

https://www.codeproject.com/Articles/18099/A-USB-HID-Component-for-C
A component to communicate with a USB HID device

Introduction
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.
Background
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.
Hide   Copy Code

protected override void OnHandleCreated(EventArgs e){base.OnHandleCreated(e);usb.RegisterHandle(Handle);}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.
History
  • 22nd March, 2007: First version, currently in development
Updates will be posted if there is a need for them.


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|抱朴守拙BBS

GMT+8, 2025-5-26 05:12 , Processed in 0.189080 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表