ホーム › Devices.Usb › USBUSER_BANDWIDTH_INFO_REQUEST
USBUSER_BANDWIDTH_INFO_REQUEST
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Header | USBUSER_REQUEST_HEADER | 16 | +0 | +0 | USBUSER要求共通ヘッダ。要求コードと結果を保持する。 |
| BandwidthInformation | USB_BANDWIDTH_INFO | 44 | +16 | +16 | バス帯域使用状況の情報を保持する。 |
各言語での定義
#include <windows.h>
// USBUSER_REQUEST_HEADER (x64 16 / x86 16 バイト)
#pragma pack(push, 1)
typedef struct USBUSER_REQUEST_HEADER {
DWORD UsbUserRequest;
USB_USER_ERROR_CODE UsbUserStatusCode;
DWORD RequestBufferLength;
DWORD ActualBufferLength;
} USBUSER_REQUEST_HEADER;
#pragma pack(pop)
// 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)
// USBUSER_BANDWIDTH_INFO_REQUEST (x64 60 / x86 60 バイト)
#pragma pack(push, 1)
typedef struct USBUSER_BANDWIDTH_INFO_REQUEST {
USBUSER_REQUEST_HEADER Header;
USB_BANDWIDTH_INFO BandwidthInformation;
} USBUSER_BANDWIDTH_INFO_REQUEST;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USBUSER_REQUEST_HEADER
{
public uint UsbUserRequest;
public int UsbUserStatusCode;
public uint RequestBufferLength;
public uint ActualBufferLength;
}
[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;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USBUSER_BANDWIDTH_INFO_REQUEST
{
public USBUSER_REQUEST_HEADER Header;
public USB_BANDWIDTH_INFO BandwidthInformation;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USBUSER_REQUEST_HEADER
Public UsbUserRequest As UInteger
Public UsbUserStatusCode As Integer
Public RequestBufferLength As UInteger
Public ActualBufferLength As UInteger
End Structure
<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
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USBUSER_BANDWIDTH_INFO_REQUEST
Public Header As USBUSER_REQUEST_HEADER
Public BandwidthInformation As USB_BANDWIDTH_INFO
End Structureimport ctypes
from ctypes import wintypes
class USBUSER_REQUEST_HEADER(ctypes.Structure):
_pack_ = 1
_fields_ = [
("UsbUserRequest", wintypes.DWORD),
("UsbUserStatusCode", ctypes.c_int),
("RequestBufferLength", wintypes.DWORD),
("ActualBufferLength", wintypes.DWORD),
]
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),
]
class USBUSER_BANDWIDTH_INFO_REQUEST(ctypes.Structure):
_pack_ = 1
_fields_ = [
("Header", USBUSER_REQUEST_HEADER),
("BandwidthInformation", USB_BANDWIDTH_INFO),
]#[repr(C, packed(1))]
pub struct USBUSER_REQUEST_HEADER {
pub UsbUserRequest: u32,
pub UsbUserStatusCode: i32,
pub RequestBufferLength: u32,
pub ActualBufferLength: u32,
}
#[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,
}
#[repr(C, packed(1))]
pub struct USBUSER_BANDWIDTH_INFO_REQUEST {
pub Header: USBUSER_REQUEST_HEADER,
pub BandwidthInformation: USB_BANDWIDTH_INFO,
}import "golang.org/x/sys/windows"
type USBUSER_REQUEST_HEADER struct {
UsbUserRequest uint32
UsbUserStatusCode int32
RequestBufferLength uint32
ActualBufferLength uint32
}
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 USBUSER_BANDWIDTH_INFO_REQUEST struct {
Header USBUSER_REQUEST_HEADER
BandwidthInformation USB_BANDWIDTH_INFO
}type
USBUSER_REQUEST_HEADER = packed record
UsbUserRequest: DWORD;
UsbUserStatusCode: Integer;
RequestBufferLength: DWORD;
ActualBufferLength: DWORD;
end;
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;
USBUSER_BANDWIDTH_INFO_REQUEST = packed record
Header: USBUSER_REQUEST_HEADER;
BandwidthInformation: USB_BANDWIDTH_INFO;
end;const USBUSER_REQUEST_HEADER = extern struct {
UsbUserRequest: u32,
UsbUserStatusCode: i32,
RequestBufferLength: u32,
ActualBufferLength: u32,
};
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,
};
const USBUSER_BANDWIDTH_INFO_REQUEST = extern struct {
Header: USBUSER_REQUEST_HEADER,
BandwidthInformation: USB_BANDWIDTH_INFO,
};type
USBUSER_REQUEST_HEADER {.packed.} = object
UsbUserRequest: uint32
UsbUserStatusCode: int32
RequestBufferLength: uint32
ActualBufferLength: uint32
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
USBUSER_BANDWIDTH_INFO_REQUEST {.packed.} = object
Header: USBUSER_REQUEST_HEADER
BandwidthInformation: USB_BANDWIDTH_INFOalign(1)
struct USBUSER_REQUEST_HEADER
{
uint UsbUserRequest;
int UsbUserStatusCode;
uint RequestBufferLength;
uint ActualBufferLength;
}
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;
}
align(1)
struct USBUSER_BANDWIDTH_INFO_REQUEST
{
USBUSER_REQUEST_HEADER Header;
USB_BANDWIDTH_INFO BandwidthInformation;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USBUSER_BANDWIDTH_INFO_REQUEST サイズ: 60 バイト(x64)
dim st, 15 ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; Header : USBUSER_REQUEST_HEADER (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; BandwidthInformation : USB_BANDWIDTH_INFO (+16, 44byte) varptr(st)+16 を基点に操作(44byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global USBUSER_REQUEST_HEADER, pack=1
#field int UsbUserRequest
#field int UsbUserStatusCode
#field int RequestBufferLength
#field int ActualBufferLength
#endstruct
#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
#defstruct global USBUSER_BANDWIDTH_INFO_REQUEST, pack=1
#field USBUSER_REQUEST_HEADER Header
#field USB_BANDWIDTH_INFO BandwidthInformation
#endstruct
stdim st, USBUSER_BANDWIDTH_INFO_REQUEST ; NSTRUCT 変数を確保