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

USB_DEVICE_PERFORMANCE_INFO

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

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

フィールド

フィールドサイズx64x86説明
BulkBytesDWORD4+0+0バルク転送の総バイト数。
ControlDataBytesDWORD4+4+4コントロール転送のデータバイト数。
IsoBytesDWORD4+8+8アイソクロナス転送の総バイト数。
InterruptBytesDWORD4+12+12インタラプト転送の総バイト数。
BulkUrbCountDWORD4+16+16バルク転送のURB数。
ControlUrbCountDWORD4+20+20コントロール転送のURB数。
IsoUrbCountDWORD4+24+24アイソクロナス転送のURB数。
InterruptUrbCountDWORD4+28+28インタラプト転送のURB数。
AllocedInterruptDWORD24+32+32割り当て済みインタラプト帯域。
AllocedIsoDWORD4+56+56割り当て済みアイソクロナス帯域。
Total32secBandwidthDWORD4+60+60直近32秒間の総帯域使用量。
TotalTtBandwidthDWORD4+64+64トランザクショントランスレータの総帯域。
DeviceDescriptionWCHAR120+68+68デバイス説明のワイド文字列。
DeviceSpeedUSB_DEVICE_SPEED4+188+188デバイスの動作速度(USB_DEVICE_SPEED列挙)。
TotalIsoLatencyDWORD4+192+192アイソクロナス転送の総レイテンシ。
DroppedIsoPacketsDWORD4+196+196破棄されたアイソクロナスパケット数。
TransferErrorsDWORD4+200+200発生した転送エラーの総数。
PciInterruptCountDWORD4+204+204PCI割り込みの発生回数。
HcIdleStateDWORD4+208+208ホストコントローラのアイドル状態値。
HcAsyncIdleStateDWORD4+212+212非同期スケジュールのアイドル状態値。
HcAsyncCacheFlushCountDWORD4+216+216非同期キャッシュフラッシュ回数。
HcPeriodicIdleStateDWORD4+220+220周期スケジュールのアイドル状態値。
HcPeriodicCacheFlushCountDWORD4+224+224周期キャッシュフラッシュ回数。

各言語での定義

#include <windows.h>

// USB_DEVICE_PERFORMANCE_INFO  (x64 228 / x86 228 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_PERFORMANCE_INFO {
    DWORD BulkBytes;
    DWORD ControlDataBytes;
    DWORD IsoBytes;
    DWORD InterruptBytes;
    DWORD BulkUrbCount;
    DWORD ControlUrbCount;
    DWORD IsoUrbCount;
    DWORD InterruptUrbCount;
    DWORD AllocedInterrupt[6];
    DWORD AllocedIso;
    DWORD Total32secBandwidth;
    DWORD TotalTtBandwidth;
    WCHAR DeviceDescription[60];
    USB_DEVICE_SPEED DeviceSpeed;
    DWORD TotalIsoLatency;
    DWORD DroppedIsoPackets;
    DWORD TransferErrors;
    DWORD PciInterruptCount;
    DWORD HcIdleState;
    DWORD HcAsyncIdleState;
    DWORD HcAsyncCacheFlushCount;
    DWORD HcPeriodicIdleState;
    DWORD HcPeriodicCacheFlushCount;
} USB_DEVICE_PERFORMANCE_INFO;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_PERFORMANCE_INFO
{
    public uint BulkBytes;
    public uint ControlDataBytes;
    public uint IsoBytes;
    public uint InterruptBytes;
    public uint BulkUrbCount;
    public uint ControlUrbCount;
    public uint IsoUrbCount;
    public uint InterruptUrbCount;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public uint[] AllocedInterrupt;
    public uint AllocedIso;
    public uint Total32secBandwidth;
    public uint TotalTtBandwidth;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 60)] public string DeviceDescription;
    public int DeviceSpeed;
    public uint TotalIsoLatency;
    public uint DroppedIsoPackets;
    public uint TransferErrors;
    public uint PciInterruptCount;
    public uint HcIdleState;
    public uint HcAsyncIdleState;
    public uint HcAsyncCacheFlushCount;
    public uint HcPeriodicIdleState;
    public uint HcPeriodicCacheFlushCount;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_PERFORMANCE_INFO
    Public BulkBytes As UInteger
    Public ControlDataBytes As UInteger
    Public IsoBytes As UInteger
    Public InterruptBytes As UInteger
    Public BulkUrbCount As UInteger
    Public ControlUrbCount As UInteger
    Public IsoUrbCount As UInteger
    Public InterruptUrbCount As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> Public AllocedInterrupt() As UInteger
    Public AllocedIso As UInteger
    Public Total32secBandwidth As UInteger
    Public TotalTtBandwidth As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=60)> Public DeviceDescription As String
    Public DeviceSpeed As Integer
    Public TotalIsoLatency As UInteger
    Public DroppedIsoPackets As UInteger
    Public TransferErrors As UInteger
    Public PciInterruptCount As UInteger
    Public HcIdleState As UInteger
    Public HcAsyncIdleState As UInteger
    Public HcAsyncCacheFlushCount As UInteger
    Public HcPeriodicIdleState As UInteger
    Public HcPeriodicCacheFlushCount As UInteger
End Structure
import ctypes
from ctypes import wintypes

class USB_DEVICE_PERFORMANCE_INFO(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("BulkBytes", wintypes.DWORD),
        ("ControlDataBytes", wintypes.DWORD),
        ("IsoBytes", wintypes.DWORD),
        ("InterruptBytes", wintypes.DWORD),
        ("BulkUrbCount", wintypes.DWORD),
        ("ControlUrbCount", wintypes.DWORD),
        ("IsoUrbCount", wintypes.DWORD),
        ("InterruptUrbCount", wintypes.DWORD),
        ("AllocedInterrupt", wintypes.DWORD * 6),
        ("AllocedIso", wintypes.DWORD),
        ("Total32secBandwidth", wintypes.DWORD),
        ("TotalTtBandwidth", wintypes.DWORD),
        ("DeviceDescription", ctypes.c_wchar * 60),
        ("DeviceSpeed", ctypes.c_int),
        ("TotalIsoLatency", wintypes.DWORD),
        ("DroppedIsoPackets", wintypes.DWORD),
        ("TransferErrors", wintypes.DWORD),
        ("PciInterruptCount", wintypes.DWORD),
        ("HcIdleState", wintypes.DWORD),
        ("HcAsyncIdleState", wintypes.DWORD),
        ("HcAsyncCacheFlushCount", wintypes.DWORD),
        ("HcPeriodicIdleState", wintypes.DWORD),
        ("HcPeriodicCacheFlushCount", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct USB_DEVICE_PERFORMANCE_INFO {
    pub BulkBytes: u32,
    pub ControlDataBytes: u32,
    pub IsoBytes: u32,
    pub InterruptBytes: u32,
    pub BulkUrbCount: u32,
    pub ControlUrbCount: u32,
    pub IsoUrbCount: u32,
    pub InterruptUrbCount: u32,
    pub AllocedInterrupt: [u32; 6],
    pub AllocedIso: u32,
    pub Total32secBandwidth: u32,
    pub TotalTtBandwidth: u32,
    pub DeviceDescription: [u16; 60],
    pub DeviceSpeed: i32,
    pub TotalIsoLatency: u32,
    pub DroppedIsoPackets: u32,
    pub TransferErrors: u32,
    pub PciInterruptCount: u32,
    pub HcIdleState: u32,
    pub HcAsyncIdleState: u32,
    pub HcAsyncCacheFlushCount: u32,
    pub HcPeriodicIdleState: u32,
    pub HcPeriodicCacheFlushCount: u32,
}
import "golang.org/x/sys/windows"

type USB_DEVICE_PERFORMANCE_INFO struct {
	BulkBytes uint32
	ControlDataBytes uint32
	IsoBytes uint32
	InterruptBytes uint32
	BulkUrbCount uint32
	ControlUrbCount uint32
	IsoUrbCount uint32
	InterruptUrbCount uint32
	AllocedInterrupt [6]uint32
	AllocedIso uint32
	Total32secBandwidth uint32
	TotalTtBandwidth uint32
	DeviceDescription [60]uint16
	DeviceSpeed int32
	TotalIsoLatency uint32
	DroppedIsoPackets uint32
	TransferErrors uint32
	PciInterruptCount uint32
	HcIdleState uint32
	HcAsyncIdleState uint32
	HcAsyncCacheFlushCount uint32
	HcPeriodicIdleState uint32
	HcPeriodicCacheFlushCount uint32
}
type
  USB_DEVICE_PERFORMANCE_INFO = packed record
    BulkBytes: DWORD;
    ControlDataBytes: DWORD;
    IsoBytes: DWORD;
    InterruptBytes: DWORD;
    BulkUrbCount: DWORD;
    ControlUrbCount: DWORD;
    IsoUrbCount: DWORD;
    InterruptUrbCount: DWORD;
    AllocedInterrupt: array[0..5] of DWORD;
    AllocedIso: DWORD;
    Total32secBandwidth: DWORD;
    TotalTtBandwidth: DWORD;
    DeviceDescription: array[0..59] of WideChar;
    DeviceSpeed: Integer;
    TotalIsoLatency: DWORD;
    DroppedIsoPackets: DWORD;
    TransferErrors: DWORD;
    PciInterruptCount: DWORD;
    HcIdleState: DWORD;
    HcAsyncIdleState: DWORD;
    HcAsyncCacheFlushCount: DWORD;
    HcPeriodicIdleState: DWORD;
    HcPeriodicCacheFlushCount: DWORD;
  end;
const USB_DEVICE_PERFORMANCE_INFO = extern struct {
    BulkBytes: u32,
    ControlDataBytes: u32,
    IsoBytes: u32,
    InterruptBytes: u32,
    BulkUrbCount: u32,
    ControlUrbCount: u32,
    IsoUrbCount: u32,
    InterruptUrbCount: u32,
    AllocedInterrupt: [6]u32,
    AllocedIso: u32,
    Total32secBandwidth: u32,
    TotalTtBandwidth: u32,
    DeviceDescription: [60]u16,
    DeviceSpeed: i32,
    TotalIsoLatency: u32,
    DroppedIsoPackets: u32,
    TransferErrors: u32,
    PciInterruptCount: u32,
    HcIdleState: u32,
    HcAsyncIdleState: u32,
    HcAsyncCacheFlushCount: u32,
    HcPeriodicIdleState: u32,
    HcPeriodicCacheFlushCount: u32,
};
type
  USB_DEVICE_PERFORMANCE_INFO {.packed.} = object
    BulkBytes: uint32
    ControlDataBytes: uint32
    IsoBytes: uint32
    InterruptBytes: uint32
    BulkUrbCount: uint32
    ControlUrbCount: uint32
    IsoUrbCount: uint32
    InterruptUrbCount: uint32
    AllocedInterrupt: array[6, uint32]
    AllocedIso: uint32
    Total32secBandwidth: uint32
    TotalTtBandwidth: uint32
    DeviceDescription: array[60, uint16]
    DeviceSpeed: int32
    TotalIsoLatency: uint32
    DroppedIsoPackets: uint32
    TransferErrors: uint32
    PciInterruptCount: uint32
    HcIdleState: uint32
    HcAsyncIdleState: uint32
    HcAsyncCacheFlushCount: uint32
    HcPeriodicIdleState: uint32
    HcPeriodicCacheFlushCount: uint32
align(1)
struct USB_DEVICE_PERFORMANCE_INFO
{
    uint BulkBytes;
    uint ControlDataBytes;
    uint IsoBytes;
    uint InterruptBytes;
    uint BulkUrbCount;
    uint ControlUrbCount;
    uint IsoUrbCount;
    uint InterruptUrbCount;
    uint[6] AllocedInterrupt;
    uint AllocedIso;
    uint Total32secBandwidth;
    uint TotalTtBandwidth;
    wchar[60] DeviceDescription;
    int DeviceSpeed;
    uint TotalIsoLatency;
    uint DroppedIsoPackets;
    uint TransferErrors;
    uint PciInterruptCount;
    uint HcIdleState;
    uint HcAsyncIdleState;
    uint HcAsyncCacheFlushCount;
    uint HcPeriodicIdleState;
    uint HcPeriodicCacheFlushCount;
}

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_PERFORMANCE_INFO サイズ: 228 バイト(x64)
dim st, 57    ; 4byte整数×57(構造体サイズ 228 / 4 切り上げ)
; BulkBytes : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ControlDataBytes : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; IsoBytes : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; InterruptBytes : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; BulkUrbCount : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ControlUrbCount : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; IsoUrbCount : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; InterruptUrbCount : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; AllocedInterrupt : DWORD (+32, 24byte)  varptr(st)+32 を基点に操作(24byte:入れ子/配列)
; AllocedIso : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; Total32secBandwidth : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; TotalTtBandwidth : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; DeviceDescription : WCHAR (+68, 120byte)  varptr(st)+68 を基点に操作(120byte:入れ子/配列)
; DeviceSpeed : USB_DEVICE_SPEED (+188, 4byte)  st.47 = 値  /  値 = st.47   (lpoke/lpeek も可)
; TotalIsoLatency : DWORD (+192, 4byte)  st.48 = 値  /  値 = st.48   (lpoke/lpeek も可)
; DroppedIsoPackets : DWORD (+196, 4byte)  st.49 = 値  /  値 = st.49   (lpoke/lpeek も可)
; TransferErrors : DWORD (+200, 4byte)  st.50 = 値  /  値 = st.50   (lpoke/lpeek も可)
; PciInterruptCount : DWORD (+204, 4byte)  st.51 = 値  /  値 = st.51   (lpoke/lpeek も可)
; HcIdleState : DWORD (+208, 4byte)  st.52 = 値  /  値 = st.52   (lpoke/lpeek も可)
; HcAsyncIdleState : DWORD (+212, 4byte)  st.53 = 値  /  値 = st.53   (lpoke/lpeek も可)
; HcAsyncCacheFlushCount : DWORD (+216, 4byte)  st.54 = 値  /  値 = st.54   (lpoke/lpeek も可)
; HcPeriodicIdleState : DWORD (+220, 4byte)  st.55 = 値  /  値 = st.55   (lpoke/lpeek も可)
; HcPeriodicCacheFlushCount : DWORD (+224, 4byte)  st.56 = 値  /  値 = st.56   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_DEVICE_PERFORMANCE_INFO, pack=1
    #field int BulkBytes
    #field int ControlDataBytes
    #field int IsoBytes
    #field int InterruptBytes
    #field int BulkUrbCount
    #field int ControlUrbCount
    #field int IsoUrbCount
    #field int InterruptUrbCount
    #field int AllocedInterrupt 6
    #field int AllocedIso
    #field int Total32secBandwidth
    #field int TotalTtBandwidth
    #field wchar DeviceDescription 60
    #field int DeviceSpeed
    #field int TotalIsoLatency
    #field int DroppedIsoPackets
    #field int TransferErrors
    #field int PciInterruptCount
    #field int HcIdleState
    #field int HcAsyncIdleState
    #field int HcAsyncCacheFlushCount
    #field int HcPeriodicIdleState
    #field int HcPeriodicCacheFlushCount
#endstruct

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