📄 usb.h
字号:
#ifndef _H_USB_
#define _H_USB_
//自定义消息 WPARAM 值
#define C_WM_CONNECT_TERMINAL 0x0001
#define C_WM_CONNECT_SKYPE 0x0002
#define C_WM_KEY_DOWN 0x0003
//自定义消息 LPARAM 值
#define C_CONNECT_OFF 0x00
#define C_CONNECT_ON 0x01
#define C_CONNECTING 0x02
#define C_VendorID 0x4D9
#define C_ProductID 0x2801
#define C_VersionNumber 0x00
#define C_KEY_REPORT 2
#define C_CMD_REPORT 2
#define C_DATA_REPORT 3
#define C_MAX_USB_DEVICE 4
void ShowMessage(CString str);
void ShowResult(void);
typedef struct _UsbDevice
{
CString DeviceName;
HANDLE hDevice;
UCHAR ReportID;
USHORT InputReportByteLength;
USHORT OutputReporByteLength;
}tUsbDevice;
typedef PVOID HDEVINFO;;
typedef struct _SP_DEVICE_INTERFACE_DATA SP_DEVICE_INTERFACE_DATA;
class CUsbTerminal
{
public:
CUsbTerminal();
~CUsbTerminal();
void UsbOpen(void);
void UsbClose(void);
void UsbWrite(UCHAR ReportId, PUCHAR data, DWORD Len);
friend UINT ThreadWaitForUsbKey(LPVOID pParam);
HWND m_Hwnd;
UINT m_Msg;
protected:
tUsbDevice UsbDevice[C_MAX_USB_DEVICE];
HANDLE m_hKeyDevice;
CWinThread *IOThread;
bool ValidReportId(UCHAR ReportId);
bool IsMyDevice(HDEVINFO hDevInfo, SP_DEVICE_INTERFACE_DATA strtInterfaceData,
USHORT VendorID, USHORT ProductID, USHORT VersionNumber);
bool SeachHIDdevice(USHORT VendorID, USHORT ProductID, USHORT VersionNumber=0);
void ReleaseSrouce(void);
void WriteReport(void);
void ReadReport(void);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -