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

USB_DEVICE_INFO

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

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

フィールド

フィールドサイズx64x86説明
DeviceStateUSB_DEVICE_STATE4+0+0デバイスの状態フラグ。
PortNumberWORD2+4+4デバイスが接続されているポート番号。
DeviceDescriptorUSB_DEVICE_DESCRIPTOR18+6+6デバイスのUSBデバイス記述子。
CurrentConfigurationValueBYTE1+24+24現在選択中のコンフィギュレーション値。
SpeedUSB_DEVICE_SPEED4+25+25デバイスの動作速度(USB_DEVICE_SPEED列挙)。
DeviceAddressWORD2+29+29デバイスに割り当てられたバスアドレス。
ConnectionIndexDWORD4+31+31接続インデックス(1始まりのポート番号)。
ConnectionStatusUSB_CONNECTION_STATUS4+35+35ポートの接続状態を示す列挙値。
PnpHardwareIdWCHAR256+39+39PnPハードウェアIDのワイド文字列。
PnpCompatibleIdWCHAR256+295+295PnP互換IDのワイド文字列。
SerialNumberIdWCHAR256+551+551デバイスのシリアル番号文字列。
PnpDeviceDescriptionWCHAR256+807+807PnPデバイス説明のワイド文字列。
NumberOfOpenPipesDWORD4+1063+1063開かれているパイプの数。
PipeListUSB_PIPE_INFO11+1067+1067各オープンパイプの情報を格納する可変長配列の先頭。

各言語での定義

#include <windows.h>

// USB_DEVICE_STATE  (x64 4 / x86 4 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_STATE {
    DWORD _bitfield;
} USB_DEVICE_STATE;
#pragma pack(pop)

// USB_DEVICE_DESCRIPTOR  (x64 18 / x86 18 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_DESCRIPTOR {
    BYTE bLength;
    BYTE bDescriptorType;
    WORD bcdUSB;
    BYTE bDeviceClass;
    BYTE bDeviceSubClass;
    BYTE bDeviceProtocol;
    BYTE bMaxPacketSize0;
    WORD idVendor;
    WORD idProduct;
    WORD bcdDevice;
    BYTE iManufacturer;
    BYTE iProduct;
    BYTE iSerialNumber;
    BYTE bNumConfigurations;
} USB_DEVICE_DESCRIPTOR;
#pragma pack(pop)

// USB_ENDPOINT_DESCRIPTOR  (x64 7 / x86 7 バイト)
#pragma pack(push, 1)
typedef struct USB_ENDPOINT_DESCRIPTOR {
    BYTE bLength;
    BYTE bDescriptorType;
    BYTE bEndpointAddress;
    BYTE bmAttributes;
    WORD wMaxPacketSize;
    BYTE bInterval;
} USB_ENDPOINT_DESCRIPTOR;
#pragma pack(pop)

// USB_PIPE_INFO  (x64 11 / x86 11 バイト)
#pragma pack(push, 1)
typedef struct USB_PIPE_INFO {
    USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
    DWORD ScheduleOffset;
} USB_PIPE_INFO;
#pragma pack(pop)

// USB_DEVICE_INFO  (x64 1078 / x86 1078 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_INFO {
    USB_DEVICE_STATE DeviceState;
    WORD PortNumber;
    USB_DEVICE_DESCRIPTOR DeviceDescriptor;
    BYTE CurrentConfigurationValue;
    USB_DEVICE_SPEED Speed;
    WORD DeviceAddress;
    DWORD ConnectionIndex;
    USB_CONNECTION_STATUS ConnectionStatus;
    WCHAR PnpHardwareId[128];
    WCHAR PnpCompatibleId[128];
    WCHAR SerialNumberId[128];
    WCHAR PnpDeviceDescription[128];
    DWORD NumberOfOpenPipes;
    USB_PIPE_INFO PipeList[1];
} USB_DEVICE_INFO;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_STATE
{
    public uint _bitfield;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_DESCRIPTOR
{
    public byte bLength;
    public byte bDescriptorType;
    public ushort bcdUSB;
    public byte bDeviceClass;
    public byte bDeviceSubClass;
    public byte bDeviceProtocol;
    public byte bMaxPacketSize0;
    public ushort idVendor;
    public ushort idProduct;
    public ushort bcdDevice;
    public byte iManufacturer;
    public byte iProduct;
    public byte iSerialNumber;
    public byte bNumConfigurations;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_ENDPOINT_DESCRIPTOR
{
    public byte bLength;
    public byte bDescriptorType;
    public byte bEndpointAddress;
    public byte bmAttributes;
    public ushort wMaxPacketSize;
    public byte bInterval;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_PIPE_INFO
{
    public USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
    public uint ScheduleOffset;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_INFO
{
    public USB_DEVICE_STATE DeviceState;
    public ushort PortNumber;
    public USB_DEVICE_DESCRIPTOR DeviceDescriptor;
    public byte CurrentConfigurationValue;
    public int Speed;
    public ushort DeviceAddress;
    public uint ConnectionIndex;
    public int ConnectionStatus;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string PnpHardwareId;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string PnpCompatibleId;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string SerialNumberId;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string PnpDeviceDescription;
    public uint NumberOfOpenPipes;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public USB_PIPE_INFO[] PipeList;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_STATE
    Public _bitfield As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_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 idVendor As UShort
    Public idProduct As UShort
    Public bcdDevice As UShort
    Public iManufacturer As Byte
    Public iProduct As Byte
    Public iSerialNumber As Byte
    Public bNumConfigurations As Byte
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_ENDPOINT_DESCRIPTOR
    Public bLength As Byte
    Public bDescriptorType As Byte
    Public bEndpointAddress As Byte
    Public bmAttributes As Byte
    Public wMaxPacketSize As UShort
    Public bInterval As Byte
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_PIPE_INFO
    Public EndpointDescriptor As USB_ENDPOINT_DESCRIPTOR
    Public ScheduleOffset As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_INFO
    Public DeviceState As USB_DEVICE_STATE
    Public PortNumber As UShort
    Public DeviceDescriptor As USB_DEVICE_DESCRIPTOR
    Public CurrentConfigurationValue As Byte
    Public Speed As Integer
    Public DeviceAddress As UShort
    Public ConnectionIndex As UInteger
    Public ConnectionStatus As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public PnpHardwareId As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public PnpCompatibleId As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public SerialNumberId As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public PnpDeviceDescription As String
    Public NumberOfOpenPipes As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public PipeList() As USB_PIPE_INFO
End Structure
import ctypes
from ctypes import wintypes

class USB_DEVICE_STATE(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("_bitfield", wintypes.DWORD),
    ]

class USB_DEVICE_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),
        ("idVendor", ctypes.c_ushort),
        ("idProduct", ctypes.c_ushort),
        ("bcdDevice", ctypes.c_ushort),
        ("iManufacturer", ctypes.c_ubyte),
        ("iProduct", ctypes.c_ubyte),
        ("iSerialNumber", ctypes.c_ubyte),
        ("bNumConfigurations", ctypes.c_ubyte),
    ]

class USB_ENDPOINT_DESCRIPTOR(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("bLength", ctypes.c_ubyte),
        ("bDescriptorType", ctypes.c_ubyte),
        ("bEndpointAddress", ctypes.c_ubyte),
        ("bmAttributes", ctypes.c_ubyte),
        ("wMaxPacketSize", ctypes.c_ushort),
        ("bInterval", ctypes.c_ubyte),
    ]

class USB_PIPE_INFO(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("EndpointDescriptor", USB_ENDPOINT_DESCRIPTOR),
        ("ScheduleOffset", wintypes.DWORD),
    ]

class USB_DEVICE_INFO(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("DeviceState", USB_DEVICE_STATE),
        ("PortNumber", ctypes.c_ushort),
        ("DeviceDescriptor", USB_DEVICE_DESCRIPTOR),
        ("CurrentConfigurationValue", ctypes.c_ubyte),
        ("Speed", ctypes.c_int),
        ("DeviceAddress", ctypes.c_ushort),
        ("ConnectionIndex", wintypes.DWORD),
        ("ConnectionStatus", ctypes.c_int),
        ("PnpHardwareId", ctypes.c_wchar * 128),
        ("PnpCompatibleId", ctypes.c_wchar * 128),
        ("SerialNumberId", ctypes.c_wchar * 128),
        ("PnpDeviceDescription", ctypes.c_wchar * 128),
        ("NumberOfOpenPipes", wintypes.DWORD),
        ("PipeList", USB_PIPE_INFO * 1),
    ]
#[repr(C, packed(1))]
pub struct USB_DEVICE_STATE {
    pub _bitfield: u32,
}

#[repr(C, packed(1))]
pub struct USB_DEVICE_DESCRIPTOR {
    pub bLength: u8,
    pub bDescriptorType: u8,
    pub bcdUSB: u16,
    pub bDeviceClass: u8,
    pub bDeviceSubClass: u8,
    pub bDeviceProtocol: u8,
    pub bMaxPacketSize0: u8,
    pub idVendor: u16,
    pub idProduct: u16,
    pub bcdDevice: u16,
    pub iManufacturer: u8,
    pub iProduct: u8,
    pub iSerialNumber: u8,
    pub bNumConfigurations: u8,
}

#[repr(C, packed(1))]
pub struct USB_ENDPOINT_DESCRIPTOR {
    pub bLength: u8,
    pub bDescriptorType: u8,
    pub bEndpointAddress: u8,
    pub bmAttributes: u8,
    pub wMaxPacketSize: u16,
    pub bInterval: u8,
}

#[repr(C, packed(1))]
pub struct USB_PIPE_INFO {
    pub EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR,
    pub ScheduleOffset: u32,
}

#[repr(C, packed(1))]
pub struct USB_DEVICE_INFO {
    pub DeviceState: USB_DEVICE_STATE,
    pub PortNumber: u16,
    pub DeviceDescriptor: USB_DEVICE_DESCRIPTOR,
    pub CurrentConfigurationValue: u8,
    pub Speed: i32,
    pub DeviceAddress: u16,
    pub ConnectionIndex: u32,
    pub ConnectionStatus: i32,
    pub PnpHardwareId: [u16; 128],
    pub PnpCompatibleId: [u16; 128],
    pub SerialNumberId: [u16; 128],
    pub PnpDeviceDescription: [u16; 128],
    pub NumberOfOpenPipes: u32,
    pub PipeList: [USB_PIPE_INFO; 1],
}
import "golang.org/x/sys/windows"

type USB_DEVICE_STATE struct {
	_bitfield uint32
}

type USB_DEVICE_DESCRIPTOR struct {
	bLength byte
	bDescriptorType byte
	bcdUSB uint16
	bDeviceClass byte
	bDeviceSubClass byte
	bDeviceProtocol byte
	bMaxPacketSize0 byte
	idVendor uint16
	idProduct uint16
	bcdDevice uint16
	iManufacturer byte
	iProduct byte
	iSerialNumber byte
	bNumConfigurations byte
}

type USB_ENDPOINT_DESCRIPTOR struct {
	bLength byte
	bDescriptorType byte
	bEndpointAddress byte
	bmAttributes byte
	wMaxPacketSize uint16
	bInterval byte
}

type USB_PIPE_INFO struct {
	EndpointDescriptor USB_ENDPOINT_DESCRIPTOR
	ScheduleOffset uint32
}

type USB_DEVICE_INFO struct {
	DeviceState USB_DEVICE_STATE
	PortNumber uint16
	DeviceDescriptor USB_DEVICE_DESCRIPTOR
	CurrentConfigurationValue byte
	Speed int32
	DeviceAddress uint16
	ConnectionIndex uint32
	ConnectionStatus int32
	PnpHardwareId [128]uint16
	PnpCompatibleId [128]uint16
	SerialNumberId [128]uint16
	PnpDeviceDescription [128]uint16
	NumberOfOpenPipes uint32
	PipeList [1]USB_PIPE_INFO
}
type
  USB_DEVICE_STATE = packed record
    _bitfield: DWORD;
  end;

  USB_DEVICE_DESCRIPTOR = packed record
    bLength: Byte;
    bDescriptorType: Byte;
    bcdUSB: Word;
    bDeviceClass: Byte;
    bDeviceSubClass: Byte;
    bDeviceProtocol: Byte;
    bMaxPacketSize0: Byte;
    idVendor: Word;
    idProduct: Word;
    bcdDevice: Word;
    iManufacturer: Byte;
    iProduct: Byte;
    iSerialNumber: Byte;
    bNumConfigurations: Byte;
  end;

  USB_ENDPOINT_DESCRIPTOR = packed record
    bLength: Byte;
    bDescriptorType: Byte;
    bEndpointAddress: Byte;
    bmAttributes: Byte;
    wMaxPacketSize: Word;
    bInterval: Byte;
  end;

  USB_PIPE_INFO = packed record
    EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR;
    ScheduleOffset: DWORD;
  end;

  USB_DEVICE_INFO = packed record
    DeviceState: USB_DEVICE_STATE;
    PortNumber: Word;
    DeviceDescriptor: USB_DEVICE_DESCRIPTOR;
    CurrentConfigurationValue: Byte;
    Speed: Integer;
    DeviceAddress: Word;
    ConnectionIndex: DWORD;
    ConnectionStatus: Integer;
    PnpHardwareId: array[0..127] of WideChar;
    PnpCompatibleId: array[0..127] of WideChar;
    SerialNumberId: array[0..127] of WideChar;
    PnpDeviceDescription: array[0..127] of WideChar;
    NumberOfOpenPipes: DWORD;
    PipeList: array[0..0] of USB_PIPE_INFO;
  end;
const USB_DEVICE_STATE = extern struct {
    _bitfield: u32,
};

const USB_DEVICE_DESCRIPTOR = extern struct {
    bLength: u8,
    bDescriptorType: u8,
    bcdUSB: u16,
    bDeviceClass: u8,
    bDeviceSubClass: u8,
    bDeviceProtocol: u8,
    bMaxPacketSize0: u8,
    idVendor: u16,
    idProduct: u16,
    bcdDevice: u16,
    iManufacturer: u8,
    iProduct: u8,
    iSerialNumber: u8,
    bNumConfigurations: u8,
};

const USB_ENDPOINT_DESCRIPTOR = extern struct {
    bLength: u8,
    bDescriptorType: u8,
    bEndpointAddress: u8,
    bmAttributes: u8,
    wMaxPacketSize: u16,
    bInterval: u8,
};

const USB_PIPE_INFO = extern struct {
    EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR,
    ScheduleOffset: u32,
};

const USB_DEVICE_INFO = extern struct {
    DeviceState: USB_DEVICE_STATE,
    PortNumber: u16,
    DeviceDescriptor: USB_DEVICE_DESCRIPTOR,
    CurrentConfigurationValue: u8,
    Speed: i32,
    DeviceAddress: u16,
    ConnectionIndex: u32,
    ConnectionStatus: i32,
    PnpHardwareId: [128]u16,
    PnpCompatibleId: [128]u16,
    SerialNumberId: [128]u16,
    PnpDeviceDescription: [128]u16,
    NumberOfOpenPipes: u32,
    PipeList: [1]USB_PIPE_INFO,
};
type
  USB_DEVICE_STATE {.packed.} = object
    _bitfield: uint32

  USB_DEVICE_DESCRIPTOR {.packed.} = object
    bLength: uint8
    bDescriptorType: uint8
    bcdUSB: uint16
    bDeviceClass: uint8
    bDeviceSubClass: uint8
    bDeviceProtocol: uint8
    bMaxPacketSize0: uint8
    idVendor: uint16
    idProduct: uint16
    bcdDevice: uint16
    iManufacturer: uint8
    iProduct: uint8
    iSerialNumber: uint8
    bNumConfigurations: uint8

  USB_ENDPOINT_DESCRIPTOR {.packed.} = object
    bLength: uint8
    bDescriptorType: uint8
    bEndpointAddress: uint8
    bmAttributes: uint8
    wMaxPacketSize: uint16
    bInterval: uint8

  USB_PIPE_INFO {.packed.} = object
    EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR
    ScheduleOffset: uint32

  USB_DEVICE_INFO {.packed.} = object
    DeviceState: USB_DEVICE_STATE
    PortNumber: uint16
    DeviceDescriptor: USB_DEVICE_DESCRIPTOR
    CurrentConfigurationValue: uint8
    Speed: int32
    DeviceAddress: uint16
    ConnectionIndex: uint32
    ConnectionStatus: int32
    PnpHardwareId: array[128, uint16]
    PnpCompatibleId: array[128, uint16]
    SerialNumberId: array[128, uint16]
    PnpDeviceDescription: array[128, uint16]
    NumberOfOpenPipes: uint32
    PipeList: array[1, USB_PIPE_INFO]
align(1)
struct USB_DEVICE_STATE
{
    uint _bitfield;
}

align(1)
struct USB_DEVICE_DESCRIPTOR
{
    ubyte bLength;
    ubyte bDescriptorType;
    ushort bcdUSB;
    ubyte bDeviceClass;
    ubyte bDeviceSubClass;
    ubyte bDeviceProtocol;
    ubyte bMaxPacketSize0;
    ushort idVendor;
    ushort idProduct;
    ushort bcdDevice;
    ubyte iManufacturer;
    ubyte iProduct;
    ubyte iSerialNumber;
    ubyte bNumConfigurations;
}

align(1)
struct USB_ENDPOINT_DESCRIPTOR
{
    ubyte bLength;
    ubyte bDescriptorType;
    ubyte bEndpointAddress;
    ubyte bmAttributes;
    ushort wMaxPacketSize;
    ubyte bInterval;
}

align(1)
struct USB_PIPE_INFO
{
    USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
    uint ScheduleOffset;
}

align(1)
struct USB_DEVICE_INFO
{
    USB_DEVICE_STATE DeviceState;
    ushort PortNumber;
    USB_DEVICE_DESCRIPTOR DeviceDescriptor;
    ubyte CurrentConfigurationValue;
    int Speed;
    ushort DeviceAddress;
    uint ConnectionIndex;
    int ConnectionStatus;
    wchar[128] PnpHardwareId;
    wchar[128] PnpCompatibleId;
    wchar[128] SerialNumberId;
    wchar[128] PnpDeviceDescription;
    uint NumberOfOpenPipes;
    USB_PIPE_INFO[1] PipeList;
}

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_INFO サイズ: 1078 バイト(x64)
dim st, 270    ; 4byte整数×270(構造体サイズ 1078 / 4 切り上げ)
; DeviceState : USB_DEVICE_STATE (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; PortNumber : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; DeviceDescriptor : USB_DEVICE_DESCRIPTOR (+6, 18byte)  varptr(st)+6 を基点に操作(18byte:入れ子/配列)
; CurrentConfigurationValue : BYTE (+24, 1byte)  poke st,24,値  /  値 = peek(st,24)
; Speed : USB_DEVICE_SPEED (+25, 4byte)  lpoke st,25,値  /  値 = lpeek(st,25)
; DeviceAddress : WORD (+29, 2byte)  wpoke st,29,値  /  値 = wpeek(st,29)
; ConnectionIndex : DWORD (+31, 4byte)  lpoke st,31,値  /  値 = lpeek(st,31)
; ConnectionStatus : USB_CONNECTION_STATUS (+35, 4byte)  lpoke st,35,値  /  値 = lpeek(st,35)
; PnpHardwareId : WCHAR (+39, 256byte)  varptr(st)+39 を基点に操作(256byte:入れ子/配列)
; PnpCompatibleId : WCHAR (+295, 256byte)  varptr(st)+295 を基点に操作(256byte:入れ子/配列)
; SerialNumberId : WCHAR (+551, 256byte)  varptr(st)+551 を基点に操作(256byte:入れ子/配列)
; PnpDeviceDescription : WCHAR (+807, 256byte)  varptr(st)+807 を基点に操作(256byte:入れ子/配列)
; NumberOfOpenPipes : DWORD (+1063, 4byte)  lpoke st,1063,値  /  値 = lpeek(st,1063)
; PipeList : USB_PIPE_INFO (+1067, 11byte)  varptr(st)+1067 を基点に操作(11byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global USB_DEVICE_STATE, pack=1
    #field int _bitfield
#endstruct

#defstruct global USB_DEVICE_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 short idVendor
    #field short idProduct
    #field short bcdDevice
    #field byte iManufacturer
    #field byte iProduct
    #field byte iSerialNumber
    #field byte bNumConfigurations
#endstruct

#defstruct global USB_ENDPOINT_DESCRIPTOR, pack=1
    #field byte bLength
    #field byte bDescriptorType
    #field byte bEndpointAddress
    #field byte bmAttributes
    #field short wMaxPacketSize
    #field byte bInterval
#endstruct

#defstruct global USB_PIPE_INFO, pack=1
    #field USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
    #field int ScheduleOffset
#endstruct

#defstruct global USB_DEVICE_INFO, pack=1
    #field USB_DEVICE_STATE DeviceState
    #field short PortNumber
    #field USB_DEVICE_DESCRIPTOR DeviceDescriptor
    #field byte CurrentConfigurationValue
    #field int Speed
    #field short DeviceAddress
    #field int ConnectionIndex
    #field int ConnectionStatus
    #field wchar PnpHardwareId 128
    #field wchar PnpCompatibleId 128
    #field wchar SerialNumberId 128
    #field wchar PnpDeviceDescription 128
    #field int NumberOfOpenPipes
    #field USB_PIPE_INFO PipeList 1
#endstruct

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