- 1、本文档共18页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
《C++实现USB+HID设备读写代码》.doc
? USB HID设备读写代码实现c++?收藏
源代码如下:(生成.dll .lib)
1.MCDInterface.h
/**MCDInterface.h*author:*data:*/
?
#ifndef MCDBOX_H_INCLUDED#define MCDBOX_H_INCLUDED
#pragma once
#define???? MCD_IOCTRL_OPEN_SIG? 0x1001#define???? MCD_IOCTRL_CLOSE_SIG 0x1002#define??MCD_IOCTRL_FIND_SIG? 0x1003
#define???? MCD_IOCTRL_READY???? 0x1003#define???? MCD_IOCTRL_UNREADY?? 0x1004
#define??KEY_0??? 0x3A#define??KEY_1??? 0x3B#define??KEY_2??? 0x3C#define??KEY_3??? 0x3D#define??KEY_4??? 0x3E#define??KEY_5??? 0x3F#define??KEY_6??? 0x40#define??KEY_7??? 0x41#define??KEY_8??? 0x42#define??KEY_9??? 0x43#define??KEY_STAR?? 0x44#define??KEY_POUND?? 0x45
#define???? MSG_HOOKOFF????? 0x16#define???? MSG_HOOKON?????? 0x12#define???? MSG_RINGING????? 0x15
#define??HID_DEVICE_REMOVE?0x76 //硬件被移走
#define???? CLIENT_READY_WRITE_SIG 0x92?? //通知设备软件正在运行,每隔一段时间向缓冲区写该数据
#define DLL_EXPORT __declspec(dllexport)#define DLL_IMPORT __declspec(dllimport)
//定义用于回调的枚举消息enum{??? MCD_CALLBACK_MSG_VERSION,//not used??? MCD_CALLBACK_MSG_SERIALNO,//not used
?MCD_CALLBACK_DEVICE_FOUND,?MCD_CALLBACK_DEVICE_NOT_FOUND,?MCD_CALLBACK_DEVICE_REMOVE,
??? MCD_CALLBACK_KEYDOWN,??? MCD_CALLBACK_KEYBUFFER_CHANGED,
??? MCD_CALLBACK_HOOKOFF,??? MCD_CALLBACK_HOOKON,??? MCD_CALLBACK_RINGING,
??? MCD_CALLBACK_MSG_WARNING = -2,??? MCD_CALLBACK_MSG_ERROR = -1,};
DLL_EXPORT unsigned long MCD_DeviceIoControl(unsigned long dwIoControlCode,??void*?lpInBuffer = 0,??unsigned long nInBufferSize = 0,??void*?lpOutBuffer = 0,?unsigned long nOutBufferSize = 0);
//定义设备状态返回信息enum{??? MCD_RETURN_SUCCESS = 0,?MCD_RETURN_FOUND_HID,??? MCD_RETURN_NO_FOUND_HID,
??? MCD_RETURN_HID_IS_OPENED,//???? MCD_RETURN_HID_NO_OPEN,//?};
#endif // MCDBOX_H_INCLUDED
2.mcdHid.h
#ifndef MCDHID_H_INCLUDED#define MCDHID_H_INCLUDED
extern C{#include setupapi.h#include hidsdi.h#include dbt.h}
typedef struct _HID_DEVICE {?????? PCHAR??????????????? DevicePath;??? HANDLE?????????????? HidDevice; // A file handle to the hid device.
???
您可能关注的文档
- 《ASS- VSU - Requirements to obtain a Shengen Visa (INVITO) (EN)》.doc
- 《Asset Valuation & Allocation Models- Prudential Financial》.pdf
- 《Asset-valuation-debt Chinese 2016》.ppt
- 《Atmel Touch Library.pdf ourdev_452103》.pdf
- 《Atomic clock transitions in silicon-based spin qubits》.pdf
- 《AU5790 Single wire CAN transceiver》.pdf
- 《aune mini usb dac se》.pdf
- 《auto optimized service convergence BS config UMTS》.pdf
- 《AutoCAD实用教程:欧式橱柜门板的建模方法》.doc
- 《Autocorrelation-Approaches-Time-Frequency-Analysis-Machinery-Vibration》.pdf
文档评论(0)