ホーム › Devices.Usb › USB_DEVICE_NODE_INFO
USB_DEVICE_NODE_INFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Sig | DWORD | 4 | +0 | +0 | 構造体を識別するシグネチャ値。 |
| LengthInBytes | DWORD | 4 | +4 | +4 | 構造体全体のバイト長。 |
| DeviceDescription | WCHAR | 80 | +8 | +8 | デバイス説明のワイド文字列。 |
| NodeType | USB_WMI_DEVICE_NODE_TYPE | 4 | +88 | +88 | デバイスノードの種別を示す列挙値(WMI)。 |
| BusAddress | USB_TOPOLOGY_ADDRESS | 32 | +92 | +92 | デバイスのトポロジ上のバスアドレス。 |
| Anonymous | _Anonymous_e__Union | 1078 | +124 | +124 | ノード種別に応じた詳細情報を保持する無名共用体。 |
共用体: _Anonymous_e__Union x64 1078B / x86 1078B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| UsbDeviceInfo | USB_DEVICE_INFO | 1078 | +0 | +0 |
| HubDeviceInfo | USB_HUB_DEVICE_INFO | 103 | +0 | +0 |
| CompositeDeviceInfo | USB_COMPOSITE_DEVICE_INFO | 33 | +0 | +0 |
| ControllerDeviceInfo | USB_CONTROLLER_DEVICE_INFO | 20 | +0 | +0 |
| DeviceInformation | BYTE | 4 | +0 | +0 |
各言語での定義
#include <windows.h>
// USB_TOPOLOGY_ADDRESS (x64 32 / x86 32 バイト)
typedef struct USB_TOPOLOGY_ADDRESS {
DWORD PciBusNumber;
DWORD PciDeviceNumber;
DWORD PciFunctionNumber;
DWORD Reserved;
WORD RootHubPortNumber;
WORD HubPortNumber[5];
WORD Reserved2;
} USB_TOPOLOGY_ADDRESS;
// USB_DEVICE_NODE_INFO (x64 1202 / x86 1202 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_NODE_INFO {
DWORD Sig;
DWORD LengthInBytes;
WCHAR DeviceDescription[40];
USB_WMI_DEVICE_NODE_TYPE NodeType;
USB_TOPOLOGY_ADDRESS BusAddress;
_Anonymous_e__Union Anonymous;
} USB_DEVICE_NODE_INFO;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USB_TOPOLOGY_ADDRESS
{
public uint PciBusNumber;
public uint PciDeviceNumber;
public uint PciFunctionNumber;
public uint Reserved;
public ushort RootHubPortNumber;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public ushort[] HubPortNumber;
public ushort Reserved2;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_NODE_INFO
{
public uint Sig;
public uint LengthInBytes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)] public string DeviceDescription;
public int NodeType;
public USB_TOPOLOGY_ADDRESS BusAddress;
public _Anonymous_e__Union Anonymous;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USB_TOPOLOGY_ADDRESS
Public PciBusNumber As UInteger
Public PciDeviceNumber As UInteger
Public PciFunctionNumber As UInteger
Public Reserved As UInteger
Public RootHubPortNumber As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=5)> Public HubPortNumber() As UShort
Public Reserved2 As UShort
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_NODE_INFO
Public Sig As UInteger
Public LengthInBytes As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=40)> Public DeviceDescription As String
Public NodeType As Integer
Public BusAddress As USB_TOPOLOGY_ADDRESS
Public Anonymous As _Anonymous_e__Union
End Structureimport ctypes
from ctypes import wintypes
class USB_TOPOLOGY_ADDRESS(ctypes.Structure):
_fields_ = [
("PciBusNumber", wintypes.DWORD),
("PciDeviceNumber", wintypes.DWORD),
("PciFunctionNumber", wintypes.DWORD),
("Reserved", wintypes.DWORD),
("RootHubPortNumber", ctypes.c_ushort),
("HubPortNumber", ctypes.c_ushort * 5),
("Reserved2", ctypes.c_ushort),
]
class USB_DEVICE_NODE_INFO(ctypes.Structure):
_pack_ = 1
_fields_ = [
("Sig", wintypes.DWORD),
("LengthInBytes", wintypes.DWORD),
("DeviceDescription", ctypes.c_wchar * 40),
("NodeType", ctypes.c_int),
("BusAddress", USB_TOPOLOGY_ADDRESS),
("Anonymous", _Anonymous_e__Union),
]#[repr(C)]
pub struct USB_TOPOLOGY_ADDRESS {
pub PciBusNumber: u32,
pub PciDeviceNumber: u32,
pub PciFunctionNumber: u32,
pub Reserved: u32,
pub RootHubPortNumber: u16,
pub HubPortNumber: [u16; 5],
pub Reserved2: u16,
}
#[repr(C, packed(1))]
pub struct USB_DEVICE_NODE_INFO {
pub Sig: u32,
pub LengthInBytes: u32,
pub DeviceDescription: [u16; 40],
pub NodeType: i32,
pub BusAddress: USB_TOPOLOGY_ADDRESS,
pub Anonymous: _Anonymous_e__Union,
}import "golang.org/x/sys/windows"
type USB_TOPOLOGY_ADDRESS struct {
PciBusNumber uint32
PciDeviceNumber uint32
PciFunctionNumber uint32
Reserved uint32
RootHubPortNumber uint16
HubPortNumber [5]uint16
Reserved2 uint16
}
type USB_DEVICE_NODE_INFO struct {
Sig uint32
LengthInBytes uint32
DeviceDescription [40]uint16
NodeType int32
BusAddress USB_TOPOLOGY_ADDRESS
Anonymous _Anonymous_e__Union
}type
USB_TOPOLOGY_ADDRESS = record
PciBusNumber: DWORD;
PciDeviceNumber: DWORD;
PciFunctionNumber: DWORD;
Reserved: DWORD;
RootHubPortNumber: Word;
HubPortNumber: array[0..4] of Word;
Reserved2: Word;
end;
USB_DEVICE_NODE_INFO = packed record
Sig: DWORD;
LengthInBytes: DWORD;
DeviceDescription: array[0..39] of WideChar;
NodeType: Integer;
BusAddress: USB_TOPOLOGY_ADDRESS;
Anonymous: _Anonymous_e__Union;
end;const USB_TOPOLOGY_ADDRESS = extern struct {
PciBusNumber: u32,
PciDeviceNumber: u32,
PciFunctionNumber: u32,
Reserved: u32,
RootHubPortNumber: u16,
HubPortNumber: [5]u16,
Reserved2: u16,
};
const USB_DEVICE_NODE_INFO = extern struct {
Sig: u32,
LengthInBytes: u32,
DeviceDescription: [40]u16,
NodeType: i32,
BusAddress: USB_TOPOLOGY_ADDRESS,
Anonymous: _Anonymous_e__Union,
};type
USB_TOPOLOGY_ADDRESS {.bycopy.} = object
PciBusNumber: uint32
PciDeviceNumber: uint32
PciFunctionNumber: uint32
Reserved: uint32
RootHubPortNumber: uint16
HubPortNumber: array[5, uint16]
Reserved2: uint16
USB_DEVICE_NODE_INFO {.packed.} = object
Sig: uint32
LengthInBytes: uint32
DeviceDescription: array[40, uint16]
NodeType: int32
BusAddress: USB_TOPOLOGY_ADDRESS
Anonymous: _Anonymous_e__Unionstruct USB_TOPOLOGY_ADDRESS
{
uint PciBusNumber;
uint PciDeviceNumber;
uint PciFunctionNumber;
uint Reserved;
ushort RootHubPortNumber;
ushort[5] HubPortNumber;
ushort Reserved2;
}
align(1)
struct USB_DEVICE_NODE_INFO
{
uint Sig;
uint LengthInBytes;
wchar[40] DeviceDescription;
int NodeType;
USB_TOPOLOGY_ADDRESS BusAddress;
_Anonymous_e__Union Anonymous;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_DEVICE_NODE_INFO サイズ: 1202 バイト(x64)
dim st, 301 ; 4byte整数×301(構造体サイズ 1202 / 4 切り上げ)
; Sig : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; LengthInBytes : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; DeviceDescription : WCHAR (+8, 80byte) varptr(st)+8 を基点に操作(80byte:入れ子/配列)
; NodeType : USB_WMI_DEVICE_NODE_TYPE (+88, 4byte) st.22 = 値 / 値 = st.22 (lpoke/lpeek も可)
; BusAddress : USB_TOPOLOGY_ADDRESS (+92, 32byte) varptr(st)+92 を基点に操作(32byte:入れ子/配列)
; Anonymous : _Anonymous_e__Union (+124, 1078byte) varptr(st)+124 を基点に操作(1078byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global USB_TOPOLOGY_ADDRESS
#field int PciBusNumber
#field int PciDeviceNumber
#field int PciFunctionNumber
#field int Reserved
#field short RootHubPortNumber
#field short HubPortNumber 5
#field short Reserved2
#endstruct
#defstruct global USB_DEVICE_NODE_INFO, pack=1
#field int Sig
#field int LengthInBytes
#field wchar DeviceDescription 40
#field int NodeType
#field USB_TOPOLOGY_ADDRESS BusAddress
#field byte Anonymous 1078
#endstruct
stdim st, USB_DEVICE_NODE_INFO ; NSTRUCT 変数を確保
st->Sig = 100
mes "Sig=" + st->Sig
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。