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

DBCOLUMNACCESS

構造体
サイズx64: 72 バイト / x86: 48 バイトパッキング2

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

フィールド

フィールドサイズx64x86説明
pDatavoid*8/4+0+0列データの読み書きに使うバッファへのポインタ。
columnidDBID32/24+8+4アクセス対象列の識別子(DBID)。
cbDataLenUINT_PTR8/4+40+28実際のデータ長(バイト数)。出力で設定される。
dwStatusDWORD4+48+32列値の状態(DBSTATUS_*)。NULL/切捨て等を表す。
cbMaxLenUINT_PTR8/4+52+36pDataバッファの最大長(バイト数)。
dwReservedUINT_PTR8/4+60+40予約フィールド(ポインタサイズ整数)。将来の拡張用。
wTypeWORD2+68+44アクセスするデータの型を示すDBTYPE値(WORD)。
bPrecisionBYTE1+70+46数値型の精度(全体桁数)。
bScaleBYTE1+71+47数値型のスケール(小数部桁数)。

各言語での定義

#include <windows.h>

// DBID  (x64 32 / x86 24 バイト)
typedef struct DBID {
    _uGuid_e__Union uGuid;
    DWORD eKind;
    _uName_e__Union uName;
} DBID;

// DBCOLUMNACCESS  (x64 72 / x86 48 バイト)
#pragma pack(push, 2)
typedef struct DBCOLUMNACCESS {
    void* pData;
    DBID columnid;
    UINT_PTR cbDataLen;
    DWORD dwStatus;
    UINT_PTR cbMaxLen;
    UINT_PTR dwReserved;
    WORD wType;
    BYTE bPrecision;
    BYTE bScale;
} DBCOLUMNACCESS;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DBID
{
    public _uGuid_e__Union uGuid;
    public uint eKind;
    public _uName_e__Union uName;
}

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct DBCOLUMNACCESS
{
    public IntPtr pData;
    public DBID columnid;
    public UIntPtr cbDataLen;
    public uint dwStatus;
    public UIntPtr cbMaxLen;
    public UIntPtr dwReserved;
    public ushort wType;
    public byte bPrecision;
    public byte bScale;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DBID
    Public uGuid As _uGuid_e__Union
    Public eKind As UInteger
    Public uName As _uName_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure DBCOLUMNACCESS
    Public pData As IntPtr
    Public columnid As DBID
    Public cbDataLen As UIntPtr
    Public dwStatus As UInteger
    Public cbMaxLen As UIntPtr
    Public dwReserved As UIntPtr
    Public wType As UShort
    Public bPrecision As Byte
    Public bScale As Byte
End Structure
import ctypes
from ctypes import wintypes

class DBID(ctypes.Structure):
    _fields_ = [
        ("uGuid", _uGuid_e__Union),
        ("eKind", wintypes.DWORD),
        ("uName", _uName_e__Union),
    ]

class DBCOLUMNACCESS(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("pData", ctypes.c_void_p),
        ("columnid", DBID),
        ("cbDataLen", ctypes.c_size_t),
        ("dwStatus", wintypes.DWORD),
        ("cbMaxLen", ctypes.c_size_t),
        ("dwReserved", ctypes.c_size_t),
        ("wType", ctypes.c_ushort),
        ("bPrecision", ctypes.c_ubyte),
        ("bScale", ctypes.c_ubyte),
    ]
#[repr(C)]
pub struct DBID {
    pub uGuid: _uGuid_e__Union,
    pub eKind: u32,
    pub uName: _uName_e__Union,
}

#[repr(C, packed(2))]
pub struct DBCOLUMNACCESS {
    pub pData: *mut core::ffi::c_void,
    pub columnid: DBID,
    pub cbDataLen: usize,
    pub dwStatus: u32,
    pub cbMaxLen: usize,
    pub dwReserved: usize,
    pub wType: u16,
    pub bPrecision: u8,
    pub bScale: u8,
}
import "golang.org/x/sys/windows"

type DBID struct {
	uGuid _uGuid_e__Union
	eKind uint32
	uName _uName_e__Union
}

type DBCOLUMNACCESS struct {
	pData uintptr
	columnid DBID
	cbDataLen uintptr
	dwStatus uint32
	cbMaxLen uintptr
	dwReserved uintptr
	wType uint16
	bPrecision byte
	bScale byte
}
type
  DBID = record
    uGuid: _uGuid_e__Union;
    eKind: DWORD;
    uName: _uName_e__Union;
  end;

  DBCOLUMNACCESS = packed record
    pData: Pointer;
    columnid: DBID;
    cbDataLen: NativeUInt;
    dwStatus: DWORD;
    cbMaxLen: NativeUInt;
    dwReserved: NativeUInt;
    wType: Word;
    bPrecision: Byte;
    bScale: Byte;
  end;
const DBID = extern struct {
    uGuid: _uGuid_e__Union,
    eKind: u32,
    uName: _uName_e__Union,
};

const DBCOLUMNACCESS = extern struct {
    pData: ?*anyopaque,
    columnid: DBID,
    cbDataLen: usize,
    dwStatus: u32,
    cbMaxLen: usize,
    dwReserved: usize,
    wType: u16,
    bPrecision: u8,
    bScale: u8,
};
type
  DBID {.bycopy.} = object
    uGuid: _uGuid_e__Union
    eKind: uint32
    uName: _uName_e__Union

  DBCOLUMNACCESS {.packed.} = object
    pData: pointer
    columnid: DBID
    cbDataLen: uint
    dwStatus: uint32
    cbMaxLen: uint
    dwReserved: uint
    wType: uint16
    bPrecision: uint8
    bScale: uint8
struct DBID
{
    _uGuid_e__Union uGuid;
    uint eKind;
    _uName_e__Union uName;
}

align(2)
struct DBCOLUMNACCESS
{
    void* pData;
    DBID columnid;
    size_t cbDataLen;
    uint dwStatus;
    size_t cbMaxLen;
    size_t dwReserved;
    ushort wType;
    ubyte bPrecision;
    ubyte bScale;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DBCOLUMNACCESS サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; pData : void* (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; columnid : DBID (+4, 24byte)  varptr(st)+4 を基点に操作(24byte:入れ子/配列)
; cbDataLen : UINT_PTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; dwStatus : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; cbMaxLen : UINT_PTR (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; dwReserved : UINT_PTR (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; wType : WORD (+44, 2byte)  wpoke st,44,値  /  値 = wpeek(st,44)
; bPrecision : BYTE (+46, 1byte)  poke st,46,値  /  値 = peek(st,46)
; bScale : BYTE (+47, 1byte)  poke st,47,値  /  値 = peek(st,47)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DBCOLUMNACCESS サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; pData : void* (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; columnid : DBID (+8, 32byte)  varptr(st)+8 を基点に操作(32byte:入れ子/配列)
; cbDataLen : UINT_PTR (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; dwStatus : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; cbMaxLen : UINT_PTR (+52, 8byte)  qpoke st,52,値 / qpeek(st,52)  ※IronHSPのみ。3.7/3.8は lpoke st,52,下位 : lpoke st,56,上位
; dwReserved : UINT_PTR (+60, 8byte)  qpoke st,60,値 / qpeek(st,60)  ※IronHSPのみ。3.7/3.8は lpoke st,60,下位 : lpoke st,64,上位
; wType : WORD (+68, 2byte)  wpoke st,68,値  /  値 = wpeek(st,68)
; bPrecision : BYTE (+70, 1byte)  poke st,70,値  /  値 = peek(st,70)
; bScale : BYTE (+71, 1byte)  poke st,71,値  /  値 = peek(st,71)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DBID
    #field byte uGuid 16
    #field int eKind
    #field byte uName 8
#endstruct

#defstruct global DBCOLUMNACCESS, pack=2
    #field intptr pData
    #field DBID columnid
    #field intptr cbDataLen
    #field int dwStatus
    #field intptr cbMaxLen
    #field intptr dwReserved
    #field short wType
    #field byte bPrecision
    #field byte bScale
#endstruct

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