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

USB_BUS_STATISTICS_0

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

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

フィールド

フィールドサイズx64x86説明
DeviceCountDWORD4+0+0バス上のデバイス数を示す。
CurrentSystemTimeLONGLONG8+4+4統計取得時のシステム時刻を示す。
CurrentUsbFrameDWORD4+12+12現在のUSBフレーム番号を示す。
BulkBytesDWORD4+16+16バルク転送した総バイト数を示す。
IsoBytesDWORD4+20+20アイソクロナス転送した総バイト数を示す。
InterruptBytesDWORD4+24+24割込転送した総バイト数を示す。
ControlDataBytesDWORD4+28+28制御転送のデータステージで転送した総バイト数を示す。
PciInterruptCountDWORD4+32+32発生したPCI割り込み回数を示す。
HardResetCountDWORD4+36+36コントローラのハードリセット回数を示す。
WorkerSignalCountDWORD4+40+40ワーカースレッドへのシグナル回数を示す。
CommonBufferBytesDWORD4+44+44共通バッファに割り当てた総バイト数を示す。
WorkerIdleTimeMsDWORD4+48+48ワーカースレッドのアイドル時間をミリ秒単位で示す。
RootHubEnabledBOOLEAN1+52+52ルートハブが有効か示す真偽値。
RootHubDevicePowerStateBYTE1+53+53ルートハブのデバイス電源状態を示す。
UnusedBYTE1+54+54未使用の予約バイト。
NameIndexBYTE1+55+55コントローラ名のインデックスを示す。

各言語での定義

#include <windows.h>

// USB_BUS_STATISTICS_0  (x64 56 / x86 56 バイト)
#pragma pack(push, 1)
typedef struct USB_BUS_STATISTICS_0 {
    DWORD DeviceCount;
    LONGLONG CurrentSystemTime;
    DWORD CurrentUsbFrame;
    DWORD BulkBytes;
    DWORD IsoBytes;
    DWORD InterruptBytes;
    DWORD ControlDataBytes;
    DWORD PciInterruptCount;
    DWORD HardResetCount;
    DWORD WorkerSignalCount;
    DWORD CommonBufferBytes;
    DWORD WorkerIdleTimeMs;
    BOOLEAN RootHubEnabled;
    BYTE RootHubDevicePowerState;
    BYTE Unused;
    BYTE NameIndex;
} USB_BUS_STATISTICS_0;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_BUS_STATISTICS_0
{
    public uint DeviceCount;
    public long CurrentSystemTime;
    public uint CurrentUsbFrame;
    public uint BulkBytes;
    public uint IsoBytes;
    public uint InterruptBytes;
    public uint ControlDataBytes;
    public uint PciInterruptCount;
    public uint HardResetCount;
    public uint WorkerSignalCount;
    public uint CommonBufferBytes;
    public uint WorkerIdleTimeMs;
    [MarshalAs(UnmanagedType.U1)] public bool RootHubEnabled;
    public byte RootHubDevicePowerState;
    public byte Unused;
    public byte NameIndex;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_BUS_STATISTICS_0
    Public DeviceCount As UInteger
    Public CurrentSystemTime As Long
    Public CurrentUsbFrame As UInteger
    Public BulkBytes As UInteger
    Public IsoBytes As UInteger
    Public InterruptBytes As UInteger
    Public ControlDataBytes As UInteger
    Public PciInterruptCount As UInteger
    Public HardResetCount As UInteger
    Public WorkerSignalCount As UInteger
    Public CommonBufferBytes As UInteger
    Public WorkerIdleTimeMs As UInteger
    <MarshalAs(UnmanagedType.U1)> Public RootHubEnabled As Boolean
    Public RootHubDevicePowerState As Byte
    Public Unused As Byte
    Public NameIndex As Byte
End Structure
import ctypes
from ctypes import wintypes

class USB_BUS_STATISTICS_0(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("DeviceCount", wintypes.DWORD),
        ("CurrentSystemTime", ctypes.c_longlong),
        ("CurrentUsbFrame", wintypes.DWORD),
        ("BulkBytes", wintypes.DWORD),
        ("IsoBytes", wintypes.DWORD),
        ("InterruptBytes", wintypes.DWORD),
        ("ControlDataBytes", wintypes.DWORD),
        ("PciInterruptCount", wintypes.DWORD),
        ("HardResetCount", wintypes.DWORD),
        ("WorkerSignalCount", wintypes.DWORD),
        ("CommonBufferBytes", wintypes.DWORD),
        ("WorkerIdleTimeMs", wintypes.DWORD),
        ("RootHubEnabled", ctypes.c_byte),
        ("RootHubDevicePowerState", ctypes.c_ubyte),
        ("Unused", ctypes.c_ubyte),
        ("NameIndex", ctypes.c_ubyte),
    ]
#[repr(C, packed(1))]
pub struct USB_BUS_STATISTICS_0 {
    pub DeviceCount: u32,
    pub CurrentSystemTime: i64,
    pub CurrentUsbFrame: u32,
    pub BulkBytes: u32,
    pub IsoBytes: u32,
    pub InterruptBytes: u32,
    pub ControlDataBytes: u32,
    pub PciInterruptCount: u32,
    pub HardResetCount: u32,
    pub WorkerSignalCount: u32,
    pub CommonBufferBytes: u32,
    pub WorkerIdleTimeMs: u32,
    pub RootHubEnabled: u8,
    pub RootHubDevicePowerState: u8,
    pub Unused: u8,
    pub NameIndex: u8,
}
import "golang.org/x/sys/windows"

type USB_BUS_STATISTICS_0 struct {
	DeviceCount uint32
	CurrentSystemTime int64
	CurrentUsbFrame uint32
	BulkBytes uint32
	IsoBytes uint32
	InterruptBytes uint32
	ControlDataBytes uint32
	PciInterruptCount uint32
	HardResetCount uint32
	WorkerSignalCount uint32
	CommonBufferBytes uint32
	WorkerIdleTimeMs uint32
	RootHubEnabled byte
	RootHubDevicePowerState byte
	Unused byte
	NameIndex byte
}
type
  USB_BUS_STATISTICS_0 = packed record
    DeviceCount: DWORD;
    CurrentSystemTime: Int64;
    CurrentUsbFrame: DWORD;
    BulkBytes: DWORD;
    IsoBytes: DWORD;
    InterruptBytes: DWORD;
    ControlDataBytes: DWORD;
    PciInterruptCount: DWORD;
    HardResetCount: DWORD;
    WorkerSignalCount: DWORD;
    CommonBufferBytes: DWORD;
    WorkerIdleTimeMs: DWORD;
    RootHubEnabled: ByteBool;
    RootHubDevicePowerState: Byte;
    Unused: Byte;
    NameIndex: Byte;
  end;
const USB_BUS_STATISTICS_0 = extern struct {
    DeviceCount: u32,
    CurrentSystemTime: i64,
    CurrentUsbFrame: u32,
    BulkBytes: u32,
    IsoBytes: u32,
    InterruptBytes: u32,
    ControlDataBytes: u32,
    PciInterruptCount: u32,
    HardResetCount: u32,
    WorkerSignalCount: u32,
    CommonBufferBytes: u32,
    WorkerIdleTimeMs: u32,
    RootHubEnabled: u8,
    RootHubDevicePowerState: u8,
    Unused: u8,
    NameIndex: u8,
};
type
  USB_BUS_STATISTICS_0 {.packed.} = object
    DeviceCount: uint32
    CurrentSystemTime: int64
    CurrentUsbFrame: uint32
    BulkBytes: uint32
    IsoBytes: uint32
    InterruptBytes: uint32
    ControlDataBytes: uint32
    PciInterruptCount: uint32
    HardResetCount: uint32
    WorkerSignalCount: uint32
    CommonBufferBytes: uint32
    WorkerIdleTimeMs: uint32
    RootHubEnabled: uint8
    RootHubDevicePowerState: uint8
    Unused: uint8
    NameIndex: uint8
align(1)
struct USB_BUS_STATISTICS_0
{
    uint DeviceCount;
    long CurrentSystemTime;
    uint CurrentUsbFrame;
    uint BulkBytes;
    uint IsoBytes;
    uint InterruptBytes;
    uint ControlDataBytes;
    uint PciInterruptCount;
    uint HardResetCount;
    uint WorkerSignalCount;
    uint CommonBufferBytes;
    uint WorkerIdleTimeMs;
    ubyte RootHubEnabled;
    ubyte RootHubDevicePowerState;
    ubyte Unused;
    ubyte NameIndex;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_BUS_STATISTICS_0 サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; DeviceCount : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; CurrentSystemTime : LONGLONG (+4, 8byte)  qpoke st,4,値 / qpeek(st,4)  ※IronHSPのみ。3.7/3.8は lpoke st,4,下位 : lpoke st,8,上位
; CurrentUsbFrame : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; BulkBytes : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; IsoBytes : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; InterruptBytes : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ControlDataBytes : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; PciInterruptCount : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; HardResetCount : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; WorkerSignalCount : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; CommonBufferBytes : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; WorkerIdleTimeMs : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; RootHubEnabled : BOOLEAN (+52, 1byte)  poke st,52,値  /  値 = peek(st,52)
; RootHubDevicePowerState : BYTE (+53, 1byte)  poke st,53,値  /  値 = peek(st,53)
; Unused : BYTE (+54, 1byte)  poke st,54,値  /  値 = peek(st,54)
; NameIndex : BYTE (+55, 1byte)  poke st,55,値  /  値 = peek(st,55)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_BUS_STATISTICS_0, pack=1
    #field int DeviceCount
    #field int64 CurrentSystemTime
    #field int CurrentUsbFrame
    #field int BulkBytes
    #field int IsoBytes
    #field int InterruptBytes
    #field int ControlDataBytes
    #field int PciInterruptCount
    #field int HardResetCount
    #field int WorkerSignalCount
    #field int CommonBufferBytes
    #field int WorkerIdleTimeMs
    #field bool1 RootHubEnabled
    #field byte RootHubDevicePowerState
    #field byte Unused
    #field byte NameIndex
#endstruct

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