ホーム › Devices.Usb › USB_HUB_INFORMATION
USB_HUB_INFORMATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| HubDescriptor | USB_HUB_DESCRIPTOR | 71 | +0 | +0 | ハブのディスクリプタを格納する。 |
| HubIsBusPowered | BOOLEAN | 1 | +71 | +71 | ハブがバス給電されているか示す真偽値。 |
各言語での定義
#include <windows.h>
// USB_HUB_DESCRIPTOR (x64 71 / x86 71 バイト)
#pragma pack(push, 1)
typedef struct USB_HUB_DESCRIPTOR {
BYTE bDescriptorLength;
BYTE bDescriptorType;
BYTE bNumberOfPorts;
WORD wHubCharacteristics;
BYTE bPowerOnToPowerGood;
BYTE bHubControlCurrent;
BYTE bRemoveAndPowerMask[64];
} USB_HUB_DESCRIPTOR;
#pragma pack(pop)
// USB_HUB_INFORMATION (x64 72 / x86 72 バイト)
typedef struct USB_HUB_INFORMATION {
USB_HUB_DESCRIPTOR HubDescriptor;
BOOLEAN HubIsBusPowered;
} USB_HUB_INFORMATION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_HUB_DESCRIPTOR
{
public byte bDescriptorLength;
public byte bDescriptorType;
public byte bNumberOfPorts;
public ushort wHubCharacteristics;
public byte bPowerOnToPowerGood;
public byte bHubControlCurrent;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public byte[] bRemoveAndPowerMask;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USB_HUB_INFORMATION
{
public USB_HUB_DESCRIPTOR HubDescriptor;
[MarshalAs(UnmanagedType.U1)] public bool HubIsBusPowered;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_HUB_DESCRIPTOR
Public bDescriptorLength As Byte
Public bDescriptorType As Byte
Public bNumberOfPorts As Byte
Public wHubCharacteristics As UShort
Public bPowerOnToPowerGood As Byte
Public bHubControlCurrent As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public bRemoveAndPowerMask() As Byte
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USB_HUB_INFORMATION
Public HubDescriptor As USB_HUB_DESCRIPTOR
<MarshalAs(UnmanagedType.U1)> Public HubIsBusPowered As Boolean
End Structureimport ctypes
from ctypes import wintypes
class USB_HUB_DESCRIPTOR(ctypes.Structure):
_pack_ = 1
_fields_ = [
("bDescriptorLength", ctypes.c_ubyte),
("bDescriptorType", ctypes.c_ubyte),
("bNumberOfPorts", ctypes.c_ubyte),
("wHubCharacteristics", ctypes.c_ushort),
("bPowerOnToPowerGood", ctypes.c_ubyte),
("bHubControlCurrent", ctypes.c_ubyte),
("bRemoveAndPowerMask", ctypes.c_ubyte * 64),
]
class USB_HUB_INFORMATION(ctypes.Structure):
_fields_ = [
("HubDescriptor", USB_HUB_DESCRIPTOR),
("HubIsBusPowered", ctypes.c_byte),
]#[repr(C, packed(1))]
pub struct USB_HUB_DESCRIPTOR {
pub bDescriptorLength: u8,
pub bDescriptorType: u8,
pub bNumberOfPorts: u8,
pub wHubCharacteristics: u16,
pub bPowerOnToPowerGood: u8,
pub bHubControlCurrent: u8,
pub bRemoveAndPowerMask: [u8; 64],
}
#[repr(C)]
pub struct USB_HUB_INFORMATION {
pub HubDescriptor: USB_HUB_DESCRIPTOR,
pub HubIsBusPowered: u8,
}import "golang.org/x/sys/windows"
type USB_HUB_DESCRIPTOR struct {
bDescriptorLength byte
bDescriptorType byte
bNumberOfPorts byte
wHubCharacteristics uint16
bPowerOnToPowerGood byte
bHubControlCurrent byte
bRemoveAndPowerMask [64]byte
}
type USB_HUB_INFORMATION struct {
HubDescriptor USB_HUB_DESCRIPTOR
HubIsBusPowered byte
}type
USB_HUB_DESCRIPTOR = packed record
bDescriptorLength: Byte;
bDescriptorType: Byte;
bNumberOfPorts: Byte;
wHubCharacteristics: Word;
bPowerOnToPowerGood: Byte;
bHubControlCurrent: Byte;
bRemoveAndPowerMask: array[0..63] of Byte;
end;
USB_HUB_INFORMATION = record
HubDescriptor: USB_HUB_DESCRIPTOR;
HubIsBusPowered: ByteBool;
end;const USB_HUB_DESCRIPTOR = extern struct {
bDescriptorLength: u8,
bDescriptorType: u8,
bNumberOfPorts: u8,
wHubCharacteristics: u16,
bPowerOnToPowerGood: u8,
bHubControlCurrent: u8,
bRemoveAndPowerMask: [64]u8,
};
const USB_HUB_INFORMATION = extern struct {
HubDescriptor: USB_HUB_DESCRIPTOR,
HubIsBusPowered: u8,
};type
USB_HUB_DESCRIPTOR {.packed.} = object
bDescriptorLength: uint8
bDescriptorType: uint8
bNumberOfPorts: uint8
wHubCharacteristics: uint16
bPowerOnToPowerGood: uint8
bHubControlCurrent: uint8
bRemoveAndPowerMask: array[64, uint8]
USB_HUB_INFORMATION {.bycopy.} = object
HubDescriptor: USB_HUB_DESCRIPTOR
HubIsBusPowered: uint8align(1)
struct USB_HUB_DESCRIPTOR
{
ubyte bDescriptorLength;
ubyte bDescriptorType;
ubyte bNumberOfPorts;
ushort wHubCharacteristics;
ubyte bPowerOnToPowerGood;
ubyte bHubControlCurrent;
ubyte[64] bRemoveAndPowerMask;
}
struct USB_HUB_INFORMATION
{
USB_HUB_DESCRIPTOR HubDescriptor;
ubyte HubIsBusPowered;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_HUB_INFORMATION サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; HubDescriptor : USB_HUB_DESCRIPTOR (+0, 71byte) varptr(st)+0 を基点に操作(71byte:入れ子/配列)
; HubIsBusPowered : BOOLEAN (+71, 1byte) poke st,71,値 / 値 = peek(st,71)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global USB_HUB_DESCRIPTOR, pack=1
#field byte bDescriptorLength
#field byte bDescriptorType
#field byte bNumberOfPorts
#field short wHubCharacteristics
#field byte bPowerOnToPowerGood
#field byte bHubControlCurrent
#field byte bRemoveAndPowerMask 64
#endstruct
#defstruct global USB_HUB_INFORMATION
#field USB_HUB_DESCRIPTOR HubDescriptor
#field bool1 HubIsBusPowered
#endstruct
stdim st, USB_HUB_INFORMATION ; NSTRUCT 変数を確保
st->HubIsBusPowered = 100
mes "HubIsBusPowered=" + st->HubIsBusPowered