ホーム › Devices.Usb › USB_BUS_STATISTICS_0
USB_BUS_STATISTICS_0
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DeviceCount | DWORD | 4 | +0 | +0 | バス上のデバイスの数です。 | ||||||||||
| CurrentSystemTime | LONGLONG | 8 | +4 | +4 | 現在のシステム時刻です。 | ||||||||||
| CurrentUsbFrame | DWORD | 4 | +12 | +12 | 現在の USB フレームの番号です。 | ||||||||||
| BulkBytes | DWORD | 4 | +16 | +16 | バルク転送データの量 (バイト単位) です。 | ||||||||||
| IsoBytes | DWORD | 4 | +20 | +20 | アイソクロナスデータの量 (バイト単位) です。 | ||||||||||
| InterruptBytes | DWORD | 4 | +24 | +24 | 割り込みデータの量 (バイト単位) です。 | ||||||||||
| ControlDataBytes | DWORD | 4 | +28 | +28 | 制御データの量 (バイト単位) です。 | ||||||||||
| PciInterruptCount | DWORD | 4 | +32 | +32 | 割り込みデータの量 (バイト単位) です。 | ||||||||||
| HardResetCount | DWORD | 4 | +36 | +36 | 発生したハードウェアバスリセットの回数です。 | ||||||||||
| WorkerSignalCount | DWORD | 4 | +40 | +40 | ワーカースレッドがタスクの完了を通知した回数です。 | ||||||||||
| CommonBufferBytes | DWORD | 4 | +44 | +44 | 共通バッファーによって転送されたバイト数です。 | ||||||||||
| WorkerIdleTimeMs | DWORD | 4 | +48 | +48 | ワーカースレッドがアイドル状態であった時間 (ミリ秒単位) です。 | ||||||||||
| RootHubEnabled | BOOLEAN | 1 | +52 | +52 | ルートハブが有効かどうかを示すブール値です。TRUE の場合、ルートハブは有効です。FALSE の場合、ルートハブは無効です。 | ||||||||||
| RootHubDevicePowerState | BYTE | 1 | +53 | +53 | ルートハブデバイスの電源状態です。このメンバーには次のいずれかの値を指定できます。
| ||||||||||
| Unused | BYTE | 1 | +54 | +54 | このメンバーが 1 の場合、バスはアクティブです。0 の場合、バスは非アクティブです。 | ||||||||||
| NameIndex | BYTE | 1 | +55 | +55 | ハブ PDO のシンボリックリンク名を生成するために使用されるインデックスです。シンボリックリンクの形式は USBPDO-n であり、n は NameIndex の値です。 |
公式ドキュメント
USB_BUS_STATISTICS_0 構造体は、バスの統計情報を取得するために IOCTL_USB_USER_REQUEST I/O 制御要求と共に使用されます。
解説(Remarks)
USB_BUS_STATISTICS_0 構造体は、USBUSER_BUS_STATISTICS_0 ユーザーモード要求と共に使用されます。この要求の説明については、IOCTL_USB_USER_REQUEST を参照してください。
Windows 8 では、この要求は正常に完了します。ただし、基になる USB 3.0 ドライバースタックから取得される値は、実際のバス統計情報を反映していません。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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 Structureimport 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: uint8align(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