Win32 API 日本語リファレンス
ホームDevices.Usb › USB_DEVICE_QUALIFIER_DESCRIPTOR

USB_DEVICE_QUALIFIER_DESCRIPTOR

構造体
サイズx64: 10 バイト / x86: 10 バイトパッキング1

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
bLengthBYTE1+0+0このディスクリプタのサイズをバイト単位で示す。
bDescriptorTypeBYTE1+1+1ディスクリプタ種別。デバイスクオリファイアは0x06。
bcdUSBWORD2+2+2対応USB仕様リリース番号をBCD形式で示す。
bDeviceClassBYTE1+4+4他速度動作時のデバイスクラスコードを示す。
bDeviceSubClassBYTE1+5+5他速度動作時のサブクラスコードを示す。
bDeviceProtocolBYTE1+6+6他速度動作時のプロトコルコードを示す。
bMaxPacketSize0BYTE1+7+7他速度動作時のエンドポイント0最大パケットサイズを示す。
bNumConfigurationsBYTE1+8+8他速度動作時のコンフィギュレーション数を示す。
bReservedBYTE1+9+9予約フィールド。0でなければならない。

各言語での定義

#include <windows.h>

// USB_DEVICE_QUALIFIER_DESCRIPTOR  (x64 10 / x86 10 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_QUALIFIER_DESCRIPTOR {
    BYTE bLength;
    BYTE bDescriptorType;
    WORD bcdUSB;
    BYTE bDeviceClass;
    BYTE bDeviceSubClass;
    BYTE bDeviceProtocol;
    BYTE bMaxPacketSize0;
    BYTE bNumConfigurations;
    BYTE bReserved;
} USB_DEVICE_QUALIFIER_DESCRIPTOR;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_QUALIFIER_DESCRIPTOR
{
    public byte bLength;
    public byte bDescriptorType;
    public ushort bcdUSB;
    public byte bDeviceClass;
    public byte bDeviceSubClass;
    public byte bDeviceProtocol;
    public byte bMaxPacketSize0;
    public byte bNumConfigurations;
    public byte bReserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_QUALIFIER_DESCRIPTOR
    Public bLength As Byte
    Public bDescriptorType As Byte
    Public bcdUSB As UShort
    Public bDeviceClass As Byte
    Public bDeviceSubClass As Byte
    Public bDeviceProtocol As Byte
    Public bMaxPacketSize0 As Byte
    Public bNumConfigurations As Byte
    Public bReserved As Byte
End Structure
import ctypes
from ctypes import wintypes

class USB_DEVICE_QUALIFIER_DESCRIPTOR(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("bLength", ctypes.c_ubyte),
        ("bDescriptorType", ctypes.c_ubyte),
        ("bcdUSB", ctypes.c_ushort),
        ("bDeviceClass", ctypes.c_ubyte),
        ("bDeviceSubClass", ctypes.c_ubyte),
        ("bDeviceProtocol", ctypes.c_ubyte),
        ("bMaxPacketSize0", ctypes.c_ubyte),
        ("bNumConfigurations", ctypes.c_ubyte),
        ("bReserved", ctypes.c_ubyte),
    ]
#[repr(C, packed(1))]
pub struct USB_DEVICE_QUALIFIER_DESCRIPTOR {
    pub bLength: u8,
    pub bDescriptorType: u8,
    pub bcdUSB: u16,
    pub bDeviceClass: u8,
    pub bDeviceSubClass: u8,
    pub bDeviceProtocol: u8,
    pub bMaxPacketSize0: u8,
    pub bNumConfigurations: u8,
    pub bReserved: u8,
}
import "golang.org/x/sys/windows"

type USB_DEVICE_QUALIFIER_DESCRIPTOR struct {
	bLength byte
	bDescriptorType byte
	bcdUSB uint16
	bDeviceClass byte
	bDeviceSubClass byte
	bDeviceProtocol byte
	bMaxPacketSize0 byte
	bNumConfigurations byte
	bReserved byte
}
type
  USB_DEVICE_QUALIFIER_DESCRIPTOR = packed record
    bLength: Byte;
    bDescriptorType: Byte;
    bcdUSB: Word;
    bDeviceClass: Byte;
    bDeviceSubClass: Byte;
    bDeviceProtocol: Byte;
    bMaxPacketSize0: Byte;
    bNumConfigurations: Byte;
    bReserved: Byte;
  end;
const USB_DEVICE_QUALIFIER_DESCRIPTOR = extern struct {
    bLength: u8,
    bDescriptorType: u8,
    bcdUSB: u16,
    bDeviceClass: u8,
    bDeviceSubClass: u8,
    bDeviceProtocol: u8,
    bMaxPacketSize0: u8,
    bNumConfigurations: u8,
    bReserved: u8,
};
type
  USB_DEVICE_QUALIFIER_DESCRIPTOR {.packed.} = object
    bLength: uint8
    bDescriptorType: uint8
    bcdUSB: uint16
    bDeviceClass: uint8
    bDeviceSubClass: uint8
    bDeviceProtocol: uint8
    bMaxPacketSize0: uint8
    bNumConfigurations: uint8
    bReserved: uint8
align(1)
struct USB_DEVICE_QUALIFIER_DESCRIPTOR
{
    ubyte bLength;
    ubyte bDescriptorType;
    ushort bcdUSB;
    ubyte bDeviceClass;
    ubyte bDeviceSubClass;
    ubyte bDeviceProtocol;
    ubyte bMaxPacketSize0;
    ubyte bNumConfigurations;
    ubyte bReserved;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_DEVICE_QUALIFIER_DESCRIPTOR サイズ: 10 バイト(x64)
dim st, 3    ; 4byte整数×3(構造体サイズ 10 / 4 切り上げ)
; bLength : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; bcdUSB : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; bDeviceClass : BYTE (+4, 1byte)  poke st,4,値  /  値 = peek(st,4)
; bDeviceSubClass : BYTE (+5, 1byte)  poke st,5,値  /  値 = peek(st,5)
; bDeviceProtocol : BYTE (+6, 1byte)  poke st,6,値  /  値 = peek(st,6)
; bMaxPacketSize0 : BYTE (+7, 1byte)  poke st,7,値  /  値 = peek(st,7)
; bNumConfigurations : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; bReserved : BYTE (+9, 1byte)  poke st,9,値  /  値 = peek(st,9)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_DEVICE_QUALIFIER_DESCRIPTOR, pack=1
    #field byte bLength
    #field byte bDescriptorType
    #field short bcdUSB
    #field byte bDeviceClass
    #field byte bDeviceSubClass
    #field byte bDeviceProtocol
    #field byte bMaxPacketSize0
    #field byte bNumConfigurations
    #field byte bReserved
#endstruct

stdim st, USB_DEVICE_QUALIFIER_DESCRIPTOR        ; NSTRUCT 変数を確保
st->bLength = 100
mes "bLength=" + st->bLength