Language
|
Description
|
C/C++
|
BOOL UsbGetStringDescriptor(IN USB_DEVICE_HANDLE hUsb,
| OUT PUSB_STRING_DESCRIPTOR pStrDescr,
|
|
Delphi
|
function UsbGetStringDescriptor(hUsd : USB_DEVICE_HANDLE;
Index : UCHAR;
LanguaugeId : LANGID;
var StrDescr : USB_STRING_DESCRIPTOR;
var StrLen : Longint) : BOOL; stdcall;
|
VB
|
Function UsbGetStringDescriptor (ByVal hUsb As Long, _
ByVal StrIndex As Byte, _
ByVal LanguageId As Integer, _
ByRef pDesc As USB_STRING_DESCRIPTOR, _
ByRef Length As Long) As Boolean
|
Parameters
| Specifies Handle to USB device.
|
| Specifies index of string descriptor.
|
| Language ID of string descriptor.
|
| Points to user allocated memory. If function succeeds this buffer is filled with data from requested descriptor up to pStrLen length.
|
| Length of pStrDescr buffer as input parameter. On successful return pStrLen equals to pStrDescr->bLength.
|
Return Value
| If function fails it return FALSE. To detect error call GetLastError function.
|
Description
| Use this function to retrieve string contained in USB string descriptor. This function can be used only after getting valid handle from OpenRapidUsb function.
|
Example
// open first RapidUSB device
USB_HANDLE hUsb = OpenRapidUsb(0);
USB_STRING_DESCRIPTOR StrDescr;
PUSB_STRING_DESCRIPTOR pStrDescr;
ULONG nBytes;
BOOL success;
nBytes = sizeof(USB_STRING_DESCRIPTOR);
// get length of string descriptor
if (UsbGetStringDescriptor(hUsb, 1, 0x409, &StrDescr, &nBytes))
{
pStrDescr = (PUSB_STRING_DESCRIPTOR) calloc(1, nBytes + 2);
if (UsbGetStringDescriptor(hUsb,StrIndex,LanguageId, pStrDescr, &nBytes))
{
// String retrieved successfully
}
free(pStrDescr);
}
CloseRapidUsb(hUsb);
|