21 //Hid(DWORD Vid, DWORD Pid) {}

22 ~Hid() ;

23 BOOL Connect() ;

24 //BOOL ChangeDevice() {}

25 BOOL WriteHid(const BYTE * WriteBuff);

26 BOOL ReadHid(BYTE * ReadBuff);

27 BOOL IsWriteValid() const { return m_WriteValid ; }

28 BOOL IsReadValid() const { return m_ReadValid ; }

29 BOOL IsConnected() const { return m_IsConnected; }

30 const string & GetDeviceIDDesc() const { return m_DeviceIdStr ;}

31 private:

32 BOOL GetWRHandle() ;

33 private:

34 HANDLE m_WriteHandle;

35 HANDLE m_ReadHandle ;

36 string m_DeviceIdStr;//设备描述字符串

37 DWORD m_PID;

38 DWORD m_VID;

39 BOOL m_IsConnected ;//是否已连接上

40 BOOL m_ReadValid;//是否可进行读操作

41 BOOL m_WriteValid;//是否可进行写操作

42 BYTE m_RWBuff[USB_BUFF_SIZE+1] ;//读写缓冲

43

44

45 } ;

46

47

48

49 #endif

50

51

52 /*hic.cpp源文件*/

53

54 #include “Hid.h”

55

56 Hid::Hid(const string &DeviceIdStr):

57 m_DeviceIdStr(DeviceIdStr)

58 {

59

60 m_WriteHandle = INVALID_HANDLE_VALUE ;

61 m_ReadHandle = INVALID_HANDLE_VALUE ;

62 m_PID = 0;

63 m_VID = 0;

64 m_IsConnected = FALSE ;

65 m_ReadValid = FALSE ;

66 m_WriteValid = FALSE;

67 strcpy((char *)m_RWBuff,“”) ;

68 }

69

70 BOOL Hid::GetWRHandle()

71 {

72 GUID InterfaceClassGuid =

73 {0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30};

74 HDEVINFO DeviceInfoTable = INVALID_HANDLE_VALUE;

75 PSP_DEVICE_INTERFACE_DATA InterfaceDataStructure = new SP_DEVICE_INTERFACE_DATA;

76 PSP_DEVICE_INTERFACE_DETAIL_DATA DetailedInterfaceDataStructure = new SP_DEVICE_INTERFACE_DETAIL_DATA;

77 SP_DEVINFO_DATA DevInfoData;

78

79 DWORD InterfaceIndex = 0;

80 DWORD StatusLastError = 0;

81 DWORD dwRegType;

82 DWORD dwRegSize;

83 DWORD StructureSize = 0;

84 PBYTE PropertyValueBuffer;

85 bool MatchFound = false;

86 DWORD ErrorStatus;

87 DeviceInfoTable = SetupDiGetClassDevs(&InterfaceClassGuid, NULL, NULL, DIGCF_PRESENT “ DIGCF_DEVICEINTERFACE);

88 while(true)

89 {

90 InterfaceDataStructure-》cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);

91 if(SetupDiEnumDeviceInterfaces(DeviceInfoTable, NULL, &InterfaceClassGuid, InterfaceIndex, InterfaceDataStructure))

92 {

93 ErrorStatus = GetLastError();

94 if(ERROR_NO_MORE_ITEMS == ErrorStatus)

95 {

96 SetupDiDestroyDeviceInfoList(DeviceInfoTable);

97 return FALSE;

98 }

99 }

100 else

101 {

102

103 ErrorStatus = GetLastError();

  • UC3846控制芯片工作原理控制图 逆变焊机原理与用途
  • 数字万用表电阻档测试二极管正反向没有阻值(使用万用表测量二极管的正向电阻,为什么各档)
  • 学单片机需要学数电模电吗(学单片机要先学数电模电吗)
  • 电工怎么选择适合自己用的万用表(电工初学者买什么样的万用表好)
  • 单片机需要同时运行多个任务怎么办(单片机怎么同时执行多个任务)
  • 电机保护的方案取决于负载的机械特性
  • 绝缘电阻表正负搭接不复零位是怎么回事
  • 短路怎么用万用表查