USB Dize Tanımlayıcıları

Cihaz, yapılandırma ve arabirim tanımlayıcıları, dize tanımlayıcılarına başvurular içerebilir. Bu konuda, cihazdan belirli bir dize tanımlayıcısının nasıl alındığı açıklanmaktadır.

Dize tanımlayıcılarına tek tabanlı dizin numarası tarafından başvurulur. Dize tanımlayıcısı bir veya daha fazla Unicode dizesi içerir; her dize, diğerlerinin başka bir dile çevrilmesidir.

Client drivers use UsbBuildGetDescriptorRequest, with DescriptorType = USB_STRING_DESCRIPTOR_TYPE, to build the request to obtain a string descriptor. The Index parameter specifies the index number, and the LanguageID parameter specifies the language ID (the same values are used as in Microsoft Win32 LANGID values). Sürücüler, cihazın hangi dil kimliklerini desteklediğini belirlemek için sıfır özel dizin numarası isteyebilir. Bu özel değer için cihaz, Unicode dizesi yerine bir dil kimlikleri dizisi döndürür.

Dize tanımlayıcısı değişken uzunlukta verilerden oluştuğundan, sürücünün bunu iki adımda alması gerekir. Önce sürücü, bir dize tanımlayıcısı, bir USB_STRING_DESCRIPTOR yapısı için üst bilgiyi tutacak kadar büyük bir veri arabelleği geçirerek isteği vermelidir. The bLength member of USB_STRING_DESCRIPTOR specifies the size in bytes of the entire descriptor. The driver then makes the same request with a data buffer of size bLength.

The following code demonstrates how to request the i-th string descriptor, with language ID langID:

USB_STRING_DESCRIPTOR USD, *pFullUSD;
UsbBuildGetDescriptorRequest(
    pURB, // points to the URB to be filled in
    sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
    USB_STRING_DESCRIPTOR_TYPE,
    i, // index of string descriptor
    langID, // language ID of string.
    &USD, // points to a USB_STRING_DESCRIPTOR.
    NULL,
    sizeof(USB_STRING_DESCRIPTOR),
    NULL
);
pFullUSD = ExAllocatePool(NonPagedPool, USD.bLength);
UsbBuildGetDescriptorRequest(
    pURB, // points to the URB to be filled in
    sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
    USB_STRING_DESCRIPTOR_TYPE,
    i, // index of string descriptor
    langID, // language ID of string
    pFullUSD,
    NULL,
    USD.bLength,
    NULL
);