关于轩氏同步器修改pid,隐藏同步器vid和pid这个问题很多朋友还不知道,今天小六来为大家解答以上的问题,现在让我们一起来看看吧!
1、pre t=;code; l=;cpp;;PSP_DEVICE_INTERFACE_DETAIL_DATA HID_FindDevices(USHORT V_ID, USHORT P_ID, unsigned short *FIFO_Lenh){GUID HidGuid;HDEVINFO DevInfo;HIDD_ATTRIBUTES DevAttributes;SP_DEVICE_INTERFACE_DATA DevData;PSP_DEVICE_INTERFACE_DETAIL_DATA DevDetail;PHIDP_PREPARSED_DATA PreparsedData;HIDP_CAPS Capabilities;ULONG Lenh;int Index;BOOL ok;HANDLE DevHandle;int DevCount = 0;/* Get GUID for all System HIDs */HidD_GetHidGuid(HidGuid);/* Get Device Information for all present devices */DevInfo = SetupDiGetClassDevs(HidGuid, NULL, NULL, (DIGCF_PRESENT DIGCF_DEVICEINTERFACE));DevData.cbSize = sizeof(DevData);DevDetail = NULL;Index = -1;*FIFO_Lenh = 0;/* Scan all Devices */do {Index++;/* Device Interface Element of a Device Information set */ok = SetupDiEnumDeviceInterfaces(DevInfo, 0, HidGuid, Index, DevData);if (!ok) break;/* Get Device Interface Details - Get Lenh */ok = SetupDiGetDeviceInterfaceDetail(DevInfo, DevData, NULL, 0, Lenh, NULL);/* Allocate memory for Device Detailed Data */DevDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(Lenh);/* Set cbSize in the DevDetail structure */DevDetail-;cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);/* Get Device Interface Details */ok = SetupDiGetDeviceInterfaceDetail(DevInfo, DevData, DevDetail, Lenh, NULL, NULL);if (!ok) {free(DevDetail);DevDetail = NULL;continue;}/* Create File for Device Read/Write */DevHandle = CreateFile(DevDetail-;DevicePath, GENERIC_READ GENERIC_WRITE, FILE_SHARE_READ FILE_SHARE_WRITE, (LPSECURITY_ATTRIBUTES)NULL,OPEN_EXISTING, 0, NULL);if (DevHandle == INVALID_HANDLE_VALUE){free(DevDetail);DevDetail = NULL;continue;}DevAttributes.Size = sizeof(DevAttributes);ok = HidD_GetAttributes(DevHandle,DevAttributes);if(!ok) {free(DevDetail);CloseHandle(DevHandle);DevDetail = NULL;continue;}if(DevAttributes.VendorID!=V_IDDevAttributes.ProductID != P_ID){free(DevDetail);CloseHandle(DevHandle);DevDetail = NULL;continue;}/* Get Preparsed Data */ok = HidD_GetPreparsedData(DevHandle, PreparsedData);if (!ok) {free(DevDetail);CloseHandle(DevHandle);DevDetail = NULL;continue;}/* Get Device;s Capabilities */HidP_GetCaps(PreparsedData, Capabilities);*FIFO_Lenh = Capabilities.InputReportByteLenh;CloseHandle (DevHandle);break;} while (DevCount 20);SetupDiDestroyDeviceInfoList (DevInfo);return DevDetail;} 打开一个指定VendorID和ProductID的HID设备extern ;C; {// Declare the C libraries usedinclude ;setupapi.h; // Must link in setupapi.libinclude ;hidsdi.h; // Must link in hid.lib}然后在setting—;Link—;object/libary modules 中添加setupapi.lib hid.lib 两个库文件。
本文分享完毕,希望对大家有所帮助。
标签:
免责声明:本文由用户上传,如有侵权请联系删除!