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

SP_DEVICE_INTERFACE_DETAIL_DATA_A

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

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

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のバイト単位サイズ。可変長DevicePathを含まない固定部サイズを設定する。
DevicePathCHAR1+4+4デバイスを開くためのデバイスパス文字列(ANSI)。可変長配列。

各言語での定義

#include <windows.h>

// SP_DEVICE_INTERFACE_DETAIL_DATA_A  (x64 5 / x86 5 バイト)
#pragma pack(push, 1)
typedef struct SP_DEVICE_INTERFACE_DETAIL_DATA_A {
    DWORD cbSize;
    CHAR DevicePath[1];
} SP_DEVICE_INTERFACE_DETAIL_DATA_A;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SP_DEVICE_INTERFACE_DETAIL_DATA_A
{
    public uint cbSize;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public sbyte[] DevicePath;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SP_DEVICE_INTERFACE_DETAIL_DATA_A
    Public cbSize As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public DevicePath() As SByte
End Structure
import ctypes
from ctypes import wintypes

class SP_DEVICE_INTERFACE_DETAIL_DATA_A(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("DevicePath", ctypes.c_byte * 1),
    ]
#[repr(C, packed(1))]
pub struct SP_DEVICE_INTERFACE_DETAIL_DATA_A {
    pub cbSize: u32,
    pub DevicePath: [i8; 1],
}
import "golang.org/x/sys/windows"

type SP_DEVICE_INTERFACE_DETAIL_DATA_A struct {
	cbSize uint32
	DevicePath [1]int8
}
type
  SP_DEVICE_INTERFACE_DETAIL_DATA_A = packed record
    cbSize: DWORD;
    DevicePath: array[0..0] of Shortint;
  end;
const SP_DEVICE_INTERFACE_DETAIL_DATA_A = extern struct {
    cbSize: u32,
    DevicePath: [1]i8,
};
type
  SP_DEVICE_INTERFACE_DETAIL_DATA_A {.packed.} = object
    cbSize: uint32
    DevicePath: array[1, int8]
align(1)
struct SP_DEVICE_INTERFACE_DETAIL_DATA_A
{
    uint cbSize;
    byte[1] DevicePath;
}

HSP用 定義

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

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

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