安装HIDcontroller控件。
1、用USB设备名获取VID,PID,建立临时缓冲区。
2、checkout建立usb设备的线程
3、拔插下来checkin销毁线程
4、通过ondata事件获取数据指针
5、通过数据指针对16进制数进行转换10进制,并处理显示
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,StdCtrls, JvHidControllerClass;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Memo1: TMemo;
JvHidDeviceController1: TJvHidDeviceController;
procedure JvHidDeviceController1Arrival(HidDev: TJvHidDevice);
procedure JvHidDeviceController1DeviceChange(Sender: TObject);
procedure JvHidDeviceController1Removal(HidDev: TJvHidDevice);
procedure JvHidDeviceController1DeviceData(HidDev: TJvHidDevice;
ReportID: Byte; const Data: Pointer; Size: Word);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }