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

DBCOLUMNDESC

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

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

フィールド

フィールドサイズx64x86説明
pwszTypeNameLPWSTR8/4+0+0列のプロバイダ固有データ型名を表すワイド文字列へのポインタ。
pTypeInfoITypeInfo*8/4+8+4列の型情報(ITypeInfo)へのポインタ。NULL可。
rgPropertySetsDBPROPSET*8/4+16+8列に適用するプロパティセット配列(DBPROPSET)へのポインタ。
pclsidGUID*8/4+24+12列のクラスID(CLSID)へのポインタ。NULL可。
cPropertySetsDWORD4+32+16rgPropertySets配列の要素数。
ulColumnSizeUINT_PTR8/4+36+20列の最大サイズ。文字列は文字数、その他はバイト数。
dbcidDBID32/24+44+24作成する列を識別するDBID。
wTypeWORD2+76+48列のデータ型を示すDBTYPE値(WORD)。
bPrecisionBYTE1+78+50数値型の精度(全体桁数)。
bScaleBYTE1+79+51数値型のスケール(小数部桁数)。

各言語での定義

#include <windows.h>

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

// DBCOLUMNDESC  (x64 80 / x86 52 バイト)
#pragma pack(push, 2)
typedef struct DBCOLUMNDESC {
    LPWSTR pwszTypeName;
    ITypeInfo* pTypeInfo;
    DBPROPSET* rgPropertySets;
    GUID* pclsid;
    DWORD cPropertySets;
    UINT_PTR ulColumnSize;
    DBID dbcid;
    WORD wType;
    BYTE bPrecision;
    BYTE bScale;
} DBCOLUMNDESC;
#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 DBCOLUMNDESC
{
    public IntPtr pwszTypeName;
    public IntPtr pTypeInfo;
    public IntPtr rgPropertySets;
    public IntPtr pclsid;
    public uint cPropertySets;
    public UIntPtr ulColumnSize;
    public DBID dbcid;
    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 DBCOLUMNDESC
    Public pwszTypeName As IntPtr
    Public pTypeInfo As IntPtr
    Public rgPropertySets As IntPtr
    Public pclsid As IntPtr
    Public cPropertySets As UInteger
    Public ulColumnSize As UIntPtr
    Public dbcid As DBID
    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 DBCOLUMNDESC(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("pwszTypeName", ctypes.c_void_p),
        ("pTypeInfo", ctypes.c_void_p),
        ("rgPropertySets", ctypes.c_void_p),
        ("pclsid", ctypes.c_void_p),
        ("cPropertySets", wintypes.DWORD),
        ("ulColumnSize", ctypes.c_size_t),
        ("dbcid", DBID),
        ("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 DBCOLUMNDESC {
    pub pwszTypeName: *mut core::ffi::c_void,
    pub pTypeInfo: *mut core::ffi::c_void,
    pub rgPropertySets: *mut core::ffi::c_void,
    pub pclsid: *mut core::ffi::c_void,
    pub cPropertySets: u32,
    pub ulColumnSize: usize,
    pub dbcid: DBID,
    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 DBCOLUMNDESC struct {
	pwszTypeName uintptr
	pTypeInfo uintptr
	rgPropertySets uintptr
	pclsid uintptr
	cPropertySets uint32
	ulColumnSize uintptr
	dbcid DBID
	wType uint16
	bPrecision byte
	bScale byte
}
type
  DBID = record
    uGuid: _uGuid_e__Union;
    eKind: DWORD;
    uName: _uName_e__Union;
  end;

  DBCOLUMNDESC = packed record
    pwszTypeName: Pointer;
    pTypeInfo: Pointer;
    rgPropertySets: Pointer;
    pclsid: Pointer;
    cPropertySets: DWORD;
    ulColumnSize: NativeUInt;
    dbcid: DBID;
    wType: Word;
    bPrecision: Byte;
    bScale: Byte;
  end;
const DBID = extern struct {
    uGuid: _uGuid_e__Union,
    eKind: u32,
    uName: _uName_e__Union,
};

const DBCOLUMNDESC = extern struct {
    pwszTypeName: ?*anyopaque,
    pTypeInfo: ?*anyopaque,
    rgPropertySets: ?*anyopaque,
    pclsid: ?*anyopaque,
    cPropertySets: u32,
    ulColumnSize: usize,
    dbcid: DBID,
    wType: u16,
    bPrecision: u8,
    bScale: u8,
};
type
  DBID {.bycopy.} = object
    uGuid: _uGuid_e__Union
    eKind: uint32
    uName: _uName_e__Union

  DBCOLUMNDESC {.packed.} = object
    pwszTypeName: pointer
    pTypeInfo: pointer
    rgPropertySets: pointer
    pclsid: pointer
    cPropertySets: uint32
    ulColumnSize: uint
    dbcid: DBID
    wType: uint16
    bPrecision: uint8
    bScale: uint8
struct DBID
{
    _uGuid_e__Union uGuid;
    uint eKind;
    _uName_e__Union uName;
}

align(2)
struct DBCOLUMNDESC
{
    void* pwszTypeName;
    void* pTypeInfo;
    void* rgPropertySets;
    void* pclsid;
    uint cPropertySets;
    size_t ulColumnSize;
    DBID dbcid;
    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 レイアウト)
; DBCOLUMNDESC サイズ: 52 バイト(x86)
dim st, 13    ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; pwszTypeName : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pTypeInfo : ITypeInfo* (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; rgPropertySets : DBPROPSET* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; pclsid : GUID* (+12, 4byte)  varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; cPropertySets : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ulColumnSize : UINT_PTR (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; dbcid : DBID (+24, 24byte)  varptr(st)+24 を基点に操作(24byte:入れ子/配列)
; wType : WORD (+48, 2byte)  wpoke st,48,値  /  値 = wpeek(st,48)
; bPrecision : BYTE (+50, 1byte)  poke st,50,値  /  値 = peek(st,50)
; bScale : BYTE (+51, 1byte)  poke st,51,値  /  値 = peek(st,51)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DBCOLUMNDESC サイズ: 80 バイト(x64)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; pwszTypeName : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; pTypeInfo : ITypeInfo* (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; rgPropertySets : DBPROPSET* (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; pclsid : GUID* (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; cPropertySets : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ulColumnSize : UINT_PTR (+36, 8byte)  qpoke st,36,値 / qpeek(st,36)  ※IronHSPのみ。3.7/3.8は lpoke st,36,下位 : lpoke st,40,上位
; dbcid : DBID (+44, 32byte)  varptr(st)+44 を基点に操作(32byte:入れ子/配列)
; wType : WORD (+76, 2byte)  wpoke st,76,値  /  値 = wpeek(st,76)
; bPrecision : BYTE (+78, 1byte)  poke st,78,値  /  値 = peek(st,78)
; bScale : BYTE (+79, 1byte)  poke st,79,値  /  値 = peek(st,79)
; ※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 DBCOLUMNDESC, pack=2
    #field intptr pwszTypeName
    #field intptr pTypeInfo
    #field intptr rgPropertySets
    #field intptr pclsid
    #field int cPropertySets
    #field intptr ulColumnSize
    #field DBID dbcid
    #field short wType
    #field byte bPrecision
    #field byte bScale
#endstruct

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