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

USB_TRANSPORT_CHARACTERISTICS

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

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0本構造体のバージョン番号。
TransportCharacteristicsFlagsDWORD4+4+4トランスポート特性を示すフラグ集合。
CurrentRoundtripLatencyInMilliSecondsULONGLONG8+8+8現在の往復レイテンシ(ミリ秒)。
MaxPotentialBandwidthULONGLONG8+16+16潜在的な最大帯域幅。

各言語での定義

#include <windows.h>

// USB_TRANSPORT_CHARACTERISTICS  (x64 24 / x86 24 バイト)
#pragma pack(push, 1)
typedef struct USB_TRANSPORT_CHARACTERISTICS {
    DWORD Version;
    DWORD TransportCharacteristicsFlags;
    ULONGLONG CurrentRoundtripLatencyInMilliSeconds;
    ULONGLONG MaxPotentialBandwidth;
} USB_TRANSPORT_CHARACTERISTICS;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_TRANSPORT_CHARACTERISTICS
{
    public uint Version;
    public uint TransportCharacteristicsFlags;
    public ulong CurrentRoundtripLatencyInMilliSeconds;
    public ulong MaxPotentialBandwidth;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_TRANSPORT_CHARACTERISTICS
    Public Version As UInteger
    Public TransportCharacteristicsFlags As UInteger
    Public CurrentRoundtripLatencyInMilliSeconds As ULong
    Public MaxPotentialBandwidth As ULong
End Structure
import ctypes
from ctypes import wintypes

class USB_TRANSPORT_CHARACTERISTICS(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("TransportCharacteristicsFlags", wintypes.DWORD),
        ("CurrentRoundtripLatencyInMilliSeconds", ctypes.c_ulonglong),
        ("MaxPotentialBandwidth", ctypes.c_ulonglong),
    ]
#[repr(C, packed(1))]
pub struct USB_TRANSPORT_CHARACTERISTICS {
    pub Version: u32,
    pub TransportCharacteristicsFlags: u32,
    pub CurrentRoundtripLatencyInMilliSeconds: u64,
    pub MaxPotentialBandwidth: u64,
}
import "golang.org/x/sys/windows"

type USB_TRANSPORT_CHARACTERISTICS struct {
	Version uint32
	TransportCharacteristicsFlags uint32
	CurrentRoundtripLatencyInMilliSeconds uint64
	MaxPotentialBandwidth uint64
}
type
  USB_TRANSPORT_CHARACTERISTICS = packed record
    Version: DWORD;
    TransportCharacteristicsFlags: DWORD;
    CurrentRoundtripLatencyInMilliSeconds: UInt64;
    MaxPotentialBandwidth: UInt64;
  end;
const USB_TRANSPORT_CHARACTERISTICS = extern struct {
    Version: u32,
    TransportCharacteristicsFlags: u32,
    CurrentRoundtripLatencyInMilliSeconds: u64,
    MaxPotentialBandwidth: u64,
};
type
  USB_TRANSPORT_CHARACTERISTICS {.packed.} = object
    Version: uint32
    TransportCharacteristicsFlags: uint32
    CurrentRoundtripLatencyInMilliSeconds: uint64
    MaxPotentialBandwidth: uint64
align(1)
struct USB_TRANSPORT_CHARACTERISTICS
{
    uint Version;
    uint TransportCharacteristicsFlags;
    ulong CurrentRoundtripLatencyInMilliSeconds;
    ulong MaxPotentialBandwidth;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_TRANSPORT_CHARACTERISTICS サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; TransportCharacteristicsFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; CurrentRoundtripLatencyInMilliSeconds : ULONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; MaxPotentialBandwidth : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_TRANSPORT_CHARACTERISTICS, pack=1
    #field int Version
    #field int TransportCharacteristicsFlags
    #field int64 CurrentRoundtripLatencyInMilliSeconds
    #field int64 MaxPotentialBandwidth
#endstruct

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