各位弟兄帮帮忙,USB读写问题?
公司里有两种USB产品,一个我可以读写,但是换成另外一个却不能读写,各位弟兄帮忙看下,兄弟我先谢谢了!
下面代码是写入,
bool Success = false;
byte[] outputReportBuffer;
outputReportBuffer = new byte[2];
outputReportBuffer[1] = 0x04;
Success = HidD_SetOutputReport(_HIDHandle, ref outputReportBuffer[0], outputReportBuffer.Length);
下面代码是读取:
bool Success = false;
byte[] inputReportBuffer;
inputReportBuffer = new byte[2];
Success1 = HidD_GetInputReport(_HIDHandle, ref inputReportBuffer[0], inputReportBuffer.Length);
(_HIDHandle的定义:
_HIDHandle = (int)FileIOApiDeclarations.CreateFile
(DevicePathName[MemberIndex],
0,
FileIOApiDeclarations.FILE_SHARE_READ | FileIOApiDeclarations.FILE_SHARE_WRITE,
ref Security,
FileIOApiDeclarations.OPEN_EXISTING,
0,
0);
以上就是换了PID和VID,一个可以读写,另一个PID和VID就不能读写了.弄了好久不知道错在哪里?