char temp[64] = " ";
GET_STRING_DESCRIPTOR_IN input;
pvBuffer = malloc (sizeof (Usb_String_Descriptor) + 128);
if (bOpenDriver (&hDevice, pcDriverName) != TRUE) // Open the driver
{
显示信息
}
#ifdef USING_MFC
input.Index = (UCHAR) pTh-> index;
input.LanguageId = 27; // NOTE: frameworks ignores it anyway
wsprintf (temp, "GetStringDescripter: Index=%d ", input.Index);
EzSendMessage (hOutputBox, LB_ADDSTRING, 0, (LPARAM)emp);
#endif
// Get the first bytes of the descriptor to determine the size of
// the entire descriptor.
if (hDevice != NULL)
{// Perform the Get-Descriptor IOCTL
bResult = DeviceIoControl (hDevice,
IOCTL_Ezusb_GET_STRING_DESCRIPTOR,
&input,
sizeof (GET_STRING_DESCRIPTOR_IN),
pvBuffer,
sizeof (Usb_String_Descriptor),
(unsigned long *)&nBytes,
NULL);
}/* if valid driver handle */
if (bResult!=TRUE)
{// This will happen with no string defined
EzSendMessage (hOutputBox, LB_ADDSTRING, 0, (LPARAM) "Get String Descriptor Failed ");
//ShowSystemError(hOutputBox);
CloseHandle (hDevice);
free (pvBuffer);
}/* if */
ulLength = GET_STRING_DESCRIPTOR_LENGTH(pvBuffer);
assert (ulLength > = 0);
// Now get the entire descriptor
pvBuffer = realloc (pvBuffer, ulLength);
if (pvBuffer)
{
// Perform the Get-Descriptor IOCTL
bResult = DeviceIoControl (hDevice,
IOCTL_Ezusb_GET_STRING_DESCRIPTOR,
&input,
ulLength,
pvBuffer,
ulLength,
(unsigned long *)&nBytes,
NULL);
if (bResult==TRUE)
{
显示信息
} 帮忙看看吧 |