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

USB_NODE_CONNECTION_ATTRIBUTES

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

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

フィールド

フィールドサイズx64x86説明
ConnectionIndexDWORD4+0+0問い合わせ対象のハブポート番号を示す。
ConnectionStatusUSB_CONNECTION_STATUS4+4+4ポートの接続状態を示すUSB_CONNECTION_STATUS列挙値。
PortAttributesDWORD4+8+8ポートの属性を示すビットフラグ。

各言語での定義

#include <windows.h>

// USB_NODE_CONNECTION_ATTRIBUTES  (x64 12 / x86 12 バイト)
#pragma pack(push, 1)
typedef struct USB_NODE_CONNECTION_ATTRIBUTES {
    DWORD ConnectionIndex;
    USB_CONNECTION_STATUS ConnectionStatus;
    DWORD PortAttributes;
} USB_NODE_CONNECTION_ATTRIBUTES;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_NODE_CONNECTION_ATTRIBUTES
{
    public uint ConnectionIndex;
    public int ConnectionStatus;
    public uint PortAttributes;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_NODE_CONNECTION_ATTRIBUTES
    Public ConnectionIndex As UInteger
    Public ConnectionStatus As Integer
    Public PortAttributes As UInteger
End Structure
import ctypes
from ctypes import wintypes

class USB_NODE_CONNECTION_ATTRIBUTES(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("ConnectionIndex", wintypes.DWORD),
        ("ConnectionStatus", ctypes.c_int),
        ("PortAttributes", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct USB_NODE_CONNECTION_ATTRIBUTES {
    pub ConnectionIndex: u32,
    pub ConnectionStatus: i32,
    pub PortAttributes: u32,
}
import "golang.org/x/sys/windows"

type USB_NODE_CONNECTION_ATTRIBUTES struct {
	ConnectionIndex uint32
	ConnectionStatus int32
	PortAttributes uint32
}
type
  USB_NODE_CONNECTION_ATTRIBUTES = packed record
    ConnectionIndex: DWORD;
    ConnectionStatus: Integer;
    PortAttributes: DWORD;
  end;
const USB_NODE_CONNECTION_ATTRIBUTES = extern struct {
    ConnectionIndex: u32,
    ConnectionStatus: i32,
    PortAttributes: u32,
};
type
  USB_NODE_CONNECTION_ATTRIBUTES {.packed.} = object
    ConnectionIndex: uint32
    ConnectionStatus: int32
    PortAttributes: uint32
align(1)
struct USB_NODE_CONNECTION_ATTRIBUTES
{
    uint ConnectionIndex;
    int ConnectionStatus;
    uint PortAttributes;
}

HSP用 定義

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

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

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