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

USB_BANDWIDTH_INFO

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

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

フィールド

フィールドサイズx64x86説明
DeviceCountDWORD4+0+0バス上のデバイス数を示す。
TotalBusBandwidthDWORD4+4+4バスの総帯域をビット毎秒で示す。
Total32secBandwidthDWORD4+8+832秒間に利用可能な総帯域を示す。
AllocedBulkAndControlDWORD4+12+12バルク・制御転送に割り当てられた帯域を示す。
AllocedIsoDWORD4+16+16アイソクロナス転送に割り当てられた帯域を示す。
AllocedInterrupt_1msDWORD4+20+201ms間隔割込転送に割り当てられた帯域を示す。
AllocedInterrupt_2msDWORD4+24+242ms間隔割込転送に割り当てられた帯域を示す。
AllocedInterrupt_4msDWORD4+28+284ms間隔割込転送に割り当てられた帯域を示す。
AllocedInterrupt_8msDWORD4+32+328ms間隔割込転送に割り当てられた帯域を示す。
AllocedInterrupt_16msDWORD4+36+3616ms間隔割込転送に割り当てられた帯域を示す。
AllocedInterrupt_32msDWORD4+40+4032ms間隔割込転送に割り当てられた帯域を示す。

各言語での定義

#include <windows.h>

// USB_BANDWIDTH_INFO  (x64 44 / x86 44 バイト)
#pragma pack(push, 1)
typedef struct USB_BANDWIDTH_INFO {
    DWORD DeviceCount;
    DWORD TotalBusBandwidth;
    DWORD Total32secBandwidth;
    DWORD AllocedBulkAndControl;
    DWORD AllocedIso;
    DWORD AllocedInterrupt_1ms;
    DWORD AllocedInterrupt_2ms;
    DWORD AllocedInterrupt_4ms;
    DWORD AllocedInterrupt_8ms;
    DWORD AllocedInterrupt_16ms;
    DWORD AllocedInterrupt_32ms;
} USB_BANDWIDTH_INFO;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_BANDWIDTH_INFO
{
    public uint DeviceCount;
    public uint TotalBusBandwidth;
    public uint Total32secBandwidth;
    public uint AllocedBulkAndControl;
    public uint AllocedIso;
    public uint AllocedInterrupt_1ms;
    public uint AllocedInterrupt_2ms;
    public uint AllocedInterrupt_4ms;
    public uint AllocedInterrupt_8ms;
    public uint AllocedInterrupt_16ms;
    public uint AllocedInterrupt_32ms;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_BANDWIDTH_INFO
    Public DeviceCount As UInteger
    Public TotalBusBandwidth As UInteger
    Public Total32secBandwidth As UInteger
    Public AllocedBulkAndControl As UInteger
    Public AllocedIso As UInteger
    Public AllocedInterrupt_1ms As UInteger
    Public AllocedInterrupt_2ms As UInteger
    Public AllocedInterrupt_4ms As UInteger
    Public AllocedInterrupt_8ms As UInteger
    Public AllocedInterrupt_16ms As UInteger
    Public AllocedInterrupt_32ms As UInteger
End Structure
import ctypes
from ctypes import wintypes

class USB_BANDWIDTH_INFO(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("DeviceCount", wintypes.DWORD),
        ("TotalBusBandwidth", wintypes.DWORD),
        ("Total32secBandwidth", wintypes.DWORD),
        ("AllocedBulkAndControl", wintypes.DWORD),
        ("AllocedIso", wintypes.DWORD),
        ("AllocedInterrupt_1ms", wintypes.DWORD),
        ("AllocedInterrupt_2ms", wintypes.DWORD),
        ("AllocedInterrupt_4ms", wintypes.DWORD),
        ("AllocedInterrupt_8ms", wintypes.DWORD),
        ("AllocedInterrupt_16ms", wintypes.DWORD),
        ("AllocedInterrupt_32ms", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct USB_BANDWIDTH_INFO {
    pub DeviceCount: u32,
    pub TotalBusBandwidth: u32,
    pub Total32secBandwidth: u32,
    pub AllocedBulkAndControl: u32,
    pub AllocedIso: u32,
    pub AllocedInterrupt_1ms: u32,
    pub AllocedInterrupt_2ms: u32,
    pub AllocedInterrupt_4ms: u32,
    pub AllocedInterrupt_8ms: u32,
    pub AllocedInterrupt_16ms: u32,
    pub AllocedInterrupt_32ms: u32,
}
import "golang.org/x/sys/windows"

type USB_BANDWIDTH_INFO struct {
	DeviceCount uint32
	TotalBusBandwidth uint32
	Total32secBandwidth uint32
	AllocedBulkAndControl uint32
	AllocedIso uint32
	AllocedInterrupt_1ms uint32
	AllocedInterrupt_2ms uint32
	AllocedInterrupt_4ms uint32
	AllocedInterrupt_8ms uint32
	AllocedInterrupt_16ms uint32
	AllocedInterrupt_32ms uint32
}
type
  USB_BANDWIDTH_INFO = packed record
    DeviceCount: DWORD;
    TotalBusBandwidth: DWORD;
    Total32secBandwidth: DWORD;
    AllocedBulkAndControl: DWORD;
    AllocedIso: DWORD;
    AllocedInterrupt_1ms: DWORD;
    AllocedInterrupt_2ms: DWORD;
    AllocedInterrupt_4ms: DWORD;
    AllocedInterrupt_8ms: DWORD;
    AllocedInterrupt_16ms: DWORD;
    AllocedInterrupt_32ms: DWORD;
  end;
const USB_BANDWIDTH_INFO = extern struct {
    DeviceCount: u32,
    TotalBusBandwidth: u32,
    Total32secBandwidth: u32,
    AllocedBulkAndControl: u32,
    AllocedIso: u32,
    AllocedInterrupt_1ms: u32,
    AllocedInterrupt_2ms: u32,
    AllocedInterrupt_4ms: u32,
    AllocedInterrupt_8ms: u32,
    AllocedInterrupt_16ms: u32,
    AllocedInterrupt_32ms: u32,
};
type
  USB_BANDWIDTH_INFO {.packed.} = object
    DeviceCount: uint32
    TotalBusBandwidth: uint32
    Total32secBandwidth: uint32
    AllocedBulkAndControl: uint32
    AllocedIso: uint32
    AllocedInterrupt_1ms: uint32
    AllocedInterrupt_2ms: uint32
    AllocedInterrupt_4ms: uint32
    AllocedInterrupt_8ms: uint32
    AllocedInterrupt_16ms: uint32
    AllocedInterrupt_32ms: uint32
align(1)
struct USB_BANDWIDTH_INFO
{
    uint DeviceCount;
    uint TotalBusBandwidth;
    uint Total32secBandwidth;
    uint AllocedBulkAndControl;
    uint AllocedIso;
    uint AllocedInterrupt_1ms;
    uint AllocedInterrupt_2ms;
    uint AllocedInterrupt_4ms;
    uint AllocedInterrupt_8ms;
    uint AllocedInterrupt_16ms;
    uint AllocedInterrupt_32ms;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_BANDWIDTH_INFO サイズ: 44 バイト(x64)
dim st, 11    ; 4byte整数×11(構造体サイズ 44 / 4 切り上げ)
; DeviceCount : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; TotalBusBandwidth : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Total32secBandwidth : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; AllocedBulkAndControl : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; AllocedIso : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; AllocedInterrupt_1ms : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; AllocedInterrupt_2ms : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; AllocedInterrupt_4ms : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; AllocedInterrupt_8ms : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; AllocedInterrupt_16ms : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; AllocedInterrupt_32ms : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_BANDWIDTH_INFO, pack=1
    #field int DeviceCount
    #field int TotalBusBandwidth
    #field int Total32secBandwidth
    #field int AllocedBulkAndControl
    #field int AllocedIso
    #field int AllocedInterrupt_1ms
    #field int AllocedInterrupt_2ms
    #field int AllocedInterrupt_4ms
    #field int AllocedInterrupt_8ms
    #field int AllocedInterrupt_16ms
    #field int AllocedInterrupt_32ms
#endstruct

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