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

USB_PORT_PROPERTIES

共用体
サイズx64: 4 バイト / x86: 4 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
ulDWORD4+0+0ポートプロパティ全体を32ビット整数として参照する共用体メンバ。
Anonymous_Anonymous_e__Struct4+0+0個々のポート属性ビットを表すビットフィールド構造体ビュー。

構造体: _Anonymous_e__Struct x64 4B / x86 4B

フィールドサイズx64x86
_bitfieldDWORD4+0+0

各言語での定義

#include <windows.h>

// USB_PORT_PROPERTIES  (x64 4 / x86 4 バイト)
#pragma pack(push, 1)
typedef struct USB_PORT_PROPERTIES {
    DWORD ul;
    _Anonymous_e__Struct Anonymous;
} USB_PORT_PROPERTIES;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_PORT_PROPERTIES
{
    public uint ul;
    public _Anonymous_e__Struct Anonymous;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_PORT_PROPERTIES
    Public ul As UInteger
    Public Anonymous As _Anonymous_e__Struct
End Structure
import ctypes
from ctypes import wintypes

class USB_PORT_PROPERTIES(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("ul", wintypes.DWORD),
        ("Anonymous", _Anonymous_e__Struct),
    ]
#[repr(C, packed(1))]
pub struct USB_PORT_PROPERTIES {
    pub ul: u32,
    pub Anonymous: _Anonymous_e__Struct,
}
import "golang.org/x/sys/windows"

type USB_PORT_PROPERTIES struct {
	ul uint32
	Anonymous _Anonymous_e__Struct
}
type
  USB_PORT_PROPERTIES = packed record
    ul: DWORD;
    Anonymous: _Anonymous_e__Struct;
  end;
const USB_PORT_PROPERTIES = extern struct {
    ul: u32,
    Anonymous: _Anonymous_e__Struct,
};
type
  USB_PORT_PROPERTIES {.packed.} = object
    ul: uint32
    Anonymous: _Anonymous_e__Struct
align(1)
struct USB_PORT_PROPERTIES
{
    uint ul;
    _Anonymous_e__Struct 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_PORT_PROPERTIES サイズ: 4 バイト(x64)
dim st, 1    ; 4byte整数×1(構造体サイズ 4 / 4 切り上げ)
; ul : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Struct (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_PORT_PROPERTIES, pack=1
    #field int ul
    #field _Anonymous_e__Struct Anonymous
#endstruct

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