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

USBFN_BUS_CONFIGURATION_INFO

構造体
サイズx64: 82 バイト / x86: 82 バイト

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

フィールド

フィールドサイズx64x86説明
ConfigurationNameWCHAR80+0+0バスコンフィギュレーション名を示すワイド文字配列。
IsCurrentBOOLEAN1+80+80現在選択中の構成か示す真偽値。
IsActiveBOOLEAN1+81+81アクティブな構成か示す真偽値。

各言語での定義

#include <windows.h>

// USBFN_BUS_CONFIGURATION_INFO  (x64 82 / x86 82 バイト)
typedef struct USBFN_BUS_CONFIGURATION_INFO {
    WCHAR ConfigurationName[40];
    BOOLEAN IsCurrent;
    BOOLEAN IsActive;
} USBFN_BUS_CONFIGURATION_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USBFN_BUS_CONFIGURATION_INFO
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)] public string ConfigurationName;
    [MarshalAs(UnmanagedType.U1)] public bool IsCurrent;
    [MarshalAs(UnmanagedType.U1)] public bool IsActive;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USBFN_BUS_CONFIGURATION_INFO
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=40)> Public ConfigurationName As String
    <MarshalAs(UnmanagedType.U1)> Public IsCurrent As Boolean
    <MarshalAs(UnmanagedType.U1)> Public IsActive As Boolean
End Structure
import ctypes
from ctypes import wintypes

class USBFN_BUS_CONFIGURATION_INFO(ctypes.Structure):
    _fields_ = [
        ("ConfigurationName", ctypes.c_wchar * 40),
        ("IsCurrent", ctypes.c_byte),
        ("IsActive", ctypes.c_byte),
    ]
#[repr(C)]
pub struct USBFN_BUS_CONFIGURATION_INFO {
    pub ConfigurationName: [u16; 40],
    pub IsCurrent: u8,
    pub IsActive: u8,
}
import "golang.org/x/sys/windows"

type USBFN_BUS_CONFIGURATION_INFO struct {
	ConfigurationName [40]uint16
	IsCurrent byte
	IsActive byte
}
type
  USBFN_BUS_CONFIGURATION_INFO = record
    ConfigurationName: array[0..39] of WideChar;
    IsCurrent: ByteBool;
    IsActive: ByteBool;
  end;
const USBFN_BUS_CONFIGURATION_INFO = extern struct {
    ConfigurationName: [40]u16,
    IsCurrent: u8,
    IsActive: u8,
};
type
  USBFN_BUS_CONFIGURATION_INFO {.bycopy.} = object
    ConfigurationName: array[40, uint16]
    IsCurrent: uint8
    IsActive: uint8
struct USBFN_BUS_CONFIGURATION_INFO
{
    wchar[40] ConfigurationName;
    ubyte IsCurrent;
    ubyte IsActive;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USBFN_BUS_CONFIGURATION_INFO サイズ: 82 バイト(x64)
dim st, 21    ; 4byte整数×21(構造体サイズ 82 / 4 切り上げ)
; ConfigurationName : WCHAR (+0, 80byte)  varptr(st)+0 を基点に操作(80byte:入れ子/配列)
; IsCurrent : BOOLEAN (+80, 1byte)  poke st,80,値  /  値 = peek(st,80)
; IsActive : BOOLEAN (+81, 1byte)  poke st,81,値  /  値 = peek(st,81)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USBFN_BUS_CONFIGURATION_INFO
    #field wchar ConfigurationName 40
    #field bool1 IsCurrent
    #field bool1 IsActive
#endstruct

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