Win32 API 日本語リファレンス
ホームSystem.Ioctl › DEVICE_DSM_DEFINITION

DEVICE_DSM_DEFINITION

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

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

フィールド

フィールドサイズx64x86説明
ActionDWORD4+0+0このDSMが対応するアクションの種類を示す値。
SingleRangeBOOLEAN1+4+4単一範囲のみを許可するかを示す真偽値。
ParameterBlockAlignmentDWORD4+8+8パラメータブロックに要求されるアライメントをバイト単位で示す。
ParameterBlockLengthDWORD4+12+12パラメータブロックのバイト長。
HasOutputBOOLEAN1+16+16出力ブロックを伴うかを示す真偽値。
OutputBlockAlignmentDWORD4+20+20出力ブロックに要求されるアライメントをバイト単位で示す。
OutputBlockLengthDWORD4+24+24出力ブロックのバイト長。

各言語での定義

#include <windows.h>

// DEVICE_DSM_DEFINITION  (x64 28 / x86 28 バイト)
typedef struct DEVICE_DSM_DEFINITION {
    DWORD Action;
    BOOLEAN SingleRange;
    DWORD ParameterBlockAlignment;
    DWORD ParameterBlockLength;
    BOOLEAN HasOutput;
    DWORD OutputBlockAlignment;
    DWORD OutputBlockLength;
} DEVICE_DSM_DEFINITION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DEVICE_DSM_DEFINITION
{
    public uint Action;
    [MarshalAs(UnmanagedType.U1)] public bool SingleRange;
    public uint ParameterBlockAlignment;
    public uint ParameterBlockLength;
    [MarshalAs(UnmanagedType.U1)] public bool HasOutput;
    public uint OutputBlockAlignment;
    public uint OutputBlockLength;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DEVICE_DSM_DEFINITION
    Public Action As UInteger
    <MarshalAs(UnmanagedType.U1)> Public SingleRange As Boolean
    Public ParameterBlockAlignment As UInteger
    Public ParameterBlockLength As UInteger
    <MarshalAs(UnmanagedType.U1)> Public HasOutput As Boolean
    Public OutputBlockAlignment As UInteger
    Public OutputBlockLength As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DEVICE_DSM_DEFINITION(ctypes.Structure):
    _fields_ = [
        ("Action", wintypes.DWORD),
        ("SingleRange", ctypes.c_byte),
        ("ParameterBlockAlignment", wintypes.DWORD),
        ("ParameterBlockLength", wintypes.DWORD),
        ("HasOutput", ctypes.c_byte),
        ("OutputBlockAlignment", wintypes.DWORD),
        ("OutputBlockLength", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DEVICE_DSM_DEFINITION {
    pub Action: u32,
    pub SingleRange: u8,
    pub ParameterBlockAlignment: u32,
    pub ParameterBlockLength: u32,
    pub HasOutput: u8,
    pub OutputBlockAlignment: u32,
    pub OutputBlockLength: u32,
}
import "golang.org/x/sys/windows"

type DEVICE_DSM_DEFINITION struct {
	Action uint32
	SingleRange byte
	ParameterBlockAlignment uint32
	ParameterBlockLength uint32
	HasOutput byte
	OutputBlockAlignment uint32
	OutputBlockLength uint32
}
type
  DEVICE_DSM_DEFINITION = record
    Action: DWORD;
    SingleRange: ByteBool;
    ParameterBlockAlignment: DWORD;
    ParameterBlockLength: DWORD;
    HasOutput: ByteBool;
    OutputBlockAlignment: DWORD;
    OutputBlockLength: DWORD;
  end;
const DEVICE_DSM_DEFINITION = extern struct {
    Action: u32,
    SingleRange: u8,
    ParameterBlockAlignment: u32,
    ParameterBlockLength: u32,
    HasOutput: u8,
    OutputBlockAlignment: u32,
    OutputBlockLength: u32,
};
type
  DEVICE_DSM_DEFINITION {.bycopy.} = object
    Action: uint32
    SingleRange: uint8
    ParameterBlockAlignment: uint32
    ParameterBlockLength: uint32
    HasOutput: uint8
    OutputBlockAlignment: uint32
    OutputBlockLength: uint32
struct DEVICE_DSM_DEFINITION
{
    uint Action;
    ubyte SingleRange;
    uint ParameterBlockAlignment;
    uint ParameterBlockLength;
    ubyte HasOutput;
    uint OutputBlockAlignment;
    uint OutputBlockLength;
}

HSP用 定義

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

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

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