_tprintf("产品版本号:0x%04x\n",attributes.versionnumber);
wchar mstring[256];
tchar buffer[256];
hidd_getmanufacturerstring(hdevicehandle,mstring,sizeof(mstring));
if (wcstombs(buffer,mstring,256) == -1) // fail
buffer[0] = null;
_tprintf("生产商:\t%s\n",buffer);
hidd_getproductstring(hdevicehandle,mstring,sizeof(mstring));
if (wcstombs(buffer,mstring,256) == -1)
buffer[0] = null;
_tprintf("产品名称:\t%s\n",buffer);
// 通信:
phidp_preparsed_data phidppreparseddata;
hidp_caps hidpcaps;
if (!hidd_getpreparseddata(hdevicehandle,&phidppreparseddata))
{
_tprintf("获取 hid prepared data 失败!\n");
return;
}
ntstatus status = hidp_getcaps(phidppreparseddata,&hidpcaps);
if (status == hidp_status_success)
{
_tprintf("cap信息如下:\n");
_tprintf(" inputreportbytelength %d\n", hidpcaps.inputreportbytelength);
_tprintf(" outputreportbytelength %d\n", hidpcaps.outputreportbytelength);
}
dword nreadbytes = 0;
byte *pinputreport = new byte[hidpcaps.inputreportbytelength];
memset(pinputreport,0,hidpcaps.inputreportbytelength);
do
{
readfile(hdevicehandle,pinputreport,hidpcaps.inputreportbytelength,&nreadbytes,null);
if (hidpcaps.inputreportbytelength == nreadbytes)
{
for(unsigned int i=0; i<(nreadbytes-1);i++)
_tprintf("%02x-",pinputreport[i]);
_tprintf("%02x\r",pinputreport[nreadbytes-1]);
}
if (pinputreport[nreadbytes-2] == 0x20) //break the loop when pressing a specific key
{
_tprintf("\n");
break;
}
sleep(10);
}while(hidpcaps.inputreportbytelength == nreadbytes);
//释放句柄资源
closehandle(hdevicehandle);
}
memberindex++;
}while(bsuccess);
setupdidestroydeviceinfolist(hdevinfo);
}