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

TWAIN_CAPABILITY

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

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

フィールド

フィールドサイズx64x86説明
lSizeINT4+0+0このケーパビリティ構造体全体のサイズをバイトで表す。
lMSGINT4+4+4TWAIN操作の種別(取得/設定/リセット等)を示すメッセージ値。
lCapIDINT4+8+8操作対象のTWAINケーパビリティ識別子を表す。
lConTypeINT4+12+12値のコンテナ型(単一値/列挙/範囲/配列)を示す。
lRCINT4+16+16TWAINリターンコード(処理結果)を表す。
lCCINT4+20+20TWAINコンディションコード(詳細エラー要因)を表す。
lDataSizeINT4+24+24Dataフィールドに格納された有効データ長をバイトで表す。
DataBYTE1+28+28ケーパビリティ値を格納する可変長バイトデータの先頭。

各言語での定義

#include <windows.h>

// TWAIN_CAPABILITY  (x64 32 / x86 32 バイト)
typedef struct TWAIN_CAPABILITY {
    INT lSize;
    INT lMSG;
    INT lCapID;
    INT lConType;
    INT lRC;
    INT lCC;
    INT lDataSize;
    BYTE Data[1];
} TWAIN_CAPABILITY;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TWAIN_CAPABILITY
{
    public int lSize;
    public int lMSG;
    public int lCapID;
    public int lConType;
    public int lRC;
    public int lCC;
    public int lDataSize;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Data;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TWAIN_CAPABILITY
    Public lSize As Integer
    Public lMSG As Integer
    Public lCapID As Integer
    Public lConType As Integer
    Public lRC As Integer
    Public lCC As Integer
    Public lDataSize As Integer
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Data() As Byte
End Structure
import ctypes
from ctypes import wintypes

class TWAIN_CAPABILITY(ctypes.Structure):
    _fields_ = [
        ("lSize", ctypes.c_int),
        ("lMSG", ctypes.c_int),
        ("lCapID", ctypes.c_int),
        ("lConType", ctypes.c_int),
        ("lRC", ctypes.c_int),
        ("lCC", ctypes.c_int),
        ("lDataSize", ctypes.c_int),
        ("Data", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct TWAIN_CAPABILITY {
    pub lSize: i32,
    pub lMSG: i32,
    pub lCapID: i32,
    pub lConType: i32,
    pub lRC: i32,
    pub lCC: i32,
    pub lDataSize: i32,
    pub Data: [u8; 1],
}
import "golang.org/x/sys/windows"

type TWAIN_CAPABILITY struct {
	lSize int32
	lMSG int32
	lCapID int32
	lConType int32
	lRC int32
	lCC int32
	lDataSize int32
	Data [1]byte
}
type
  TWAIN_CAPABILITY = record
    lSize: Integer;
    lMSG: Integer;
    lCapID: Integer;
    lConType: Integer;
    lRC: Integer;
    lCC: Integer;
    lDataSize: Integer;
    Data: array[0..0] of Byte;
  end;
const TWAIN_CAPABILITY = extern struct {
    lSize: i32,
    lMSG: i32,
    lCapID: i32,
    lConType: i32,
    lRC: i32,
    lCC: i32,
    lDataSize: i32,
    Data: [1]u8,
};
type
  TWAIN_CAPABILITY {.bycopy.} = object
    lSize: int32
    lMSG: int32
    lCapID: int32
    lConType: int32
    lRC: int32
    lCC: int32
    lDataSize: int32
    Data: array[1, uint8]
struct TWAIN_CAPABILITY
{
    int lSize;
    int lMSG;
    int lCapID;
    int lConType;
    int lRC;
    int lCC;
    int lDataSize;
    ubyte[1] Data;
}

HSP用 定義

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

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

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