Desktop Functions: Smart Device Functions:
|
Search Results for "USB_STRING_DESCRIPTOR" in [All]ConstantsStructures
const int USB_STRING_DESCRIPTOR_TYPE = 3; The USB_DESCRIPTOR_REQUEST structure is always followed by either a USB_STRING_DESCRIPTOR or USB_DEVICE_DESCRIPTOR structure. The use of a a zero-length array at the end of the structure requires that you read and write "off the edge" of the structure. This concept is not well supported in C#/VB.Net so you have make sure that you allocate sufficient buffer space to accommodate a the USB_STRING_DESCRIPTOR or USB_DEVICE_DESCRIPTOR structure.
Request.SetupPacket.wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);
USB_STRING_DESCRIPTOR StringDesc = (USB_STRING_DESCRIPTOR)Marshal.PtrToStructure(ptrStringDesc, typeof(USB_STRING_DESCRIPTOR)); The values for iManufacturer, iProduct, and iSerialNumber are just indexs that are used by the USB_STRING_DESCRIPTOR request
struct USB_STRING_DESCRIPTOR
Structure USB_STRING_DESCRIPTOR
const int USB_STRING_DESCRIPTOR_TYPE = 3;
typedef struct _USB_STRING_DESCRIPTOR {
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR; You don't use an IOCTL call directly with a USB_STRING_DESCRIPTOR structure. Instead you use a USB_DESCRIPTOR_REQUEST "request packet" with IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION. The USB_STRING_DESCRIPTOR structure is returned at the very end of the request packet. The whole idea of "writing off the edge" of a structure is counter to the way C#/VB.Net was designed to work, so you'll have to make sure to allocate sufficient amount of memory to handle both the "request packet" and the USB_STRING_DESCRIPTOR structure.
Request.SetupPacket.wValue = (short)((USB_STRING_DESCRIPTOR_TYPE << 8) + PortDeviceDescriptor.iManufacturer);
USB_STRING_DESCRIPTOR StringDesc = (USB_STRING_DESCRIPTOR)Marshal.PtrToStructure(ptrStringDesc, typeof(USB_STRING_DESCRIPTOR)); |