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

DBCONSTRAINTDESC

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

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

フィールド

フィールドサイズx64x86説明
pConstraintIDDBID*8/4+0+0制約の識別子(DBID)へのポインタ。NULL可。
ConstraintTypeDWORD4+8+4制約の種類(主キー/一意/外部キー/チェック等、DBCONSTRAINTTYPE_*)。
cColumnsUINT_PTR8/4+12+8rgColumnList配列の列数(制約対象列数)。
rgColumnListDBID*8/4+20+12制約が適用される列ID(DBID)配列へのポインタ。
pReferencedTableIDDBID*8/4+28+16外部キー制約で参照されるテーブルのID(DBID)へのポインタ。NULL可。
cForeignKeyColumnsUINT_PTR8/4+36+20rgForeignKeyColumnList配列の列数。
rgForeignKeyColumnListDBID*8/4+44+24外部キーが参照する列ID(DBID)配列へのポインタ。NULL可。
pwszConstraintTextLPWSTR8/4+52+28チェック制約の条件式テキストを表すワイド文字列へのポインタ。NULL可。
UpdateRuleDWORD4+60+32参照先更新時の動作規則(CASCADE/NO ACTION等、DBUPDELRULE_*)。
DeleteRuleDWORD4+64+36参照先削除時の動作規則(CASCADE/NO ACTION等、DBUPDELRULE_*)。
MatchTypeDWORD4+68+40外部キーの一致方式(FULL/PARTIAL等、DBMATCHTYPE_*)。
DeferrabilityDWORD4+72+44制約評価の遅延可否(DBDEFERRABILITY_*)。
cReservedUINT_PTR8/4+76+48rgReserved配列の要素数。
rgReservedDBPROPSET*8/4+84+52予約プロパティセット配列(DBPROPSET)へのポインタ。将来の拡張用。

各言語での定義

#include <windows.h>

// DBCONSTRAINTDESC  (x64 92 / x86 56 バイト)
#pragma pack(push, 2)
typedef struct DBCONSTRAINTDESC {
    DBID* pConstraintID;
    DWORD ConstraintType;
    UINT_PTR cColumns;
    DBID* rgColumnList;
    DBID* pReferencedTableID;
    UINT_PTR cForeignKeyColumns;
    DBID* rgForeignKeyColumnList;
    LPWSTR pwszConstraintText;
    DWORD UpdateRule;
    DWORD DeleteRule;
    DWORD MatchType;
    DWORD Deferrability;
    UINT_PTR cReserved;
    DBPROPSET* rgReserved;
} DBCONSTRAINTDESC;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct DBCONSTRAINTDESC
{
    public IntPtr pConstraintID;
    public uint ConstraintType;
    public UIntPtr cColumns;
    public IntPtr rgColumnList;
    public IntPtr pReferencedTableID;
    public UIntPtr cForeignKeyColumns;
    public IntPtr rgForeignKeyColumnList;
    public IntPtr pwszConstraintText;
    public uint UpdateRule;
    public uint DeleteRule;
    public uint MatchType;
    public uint Deferrability;
    public UIntPtr cReserved;
    public IntPtr rgReserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure DBCONSTRAINTDESC
    Public pConstraintID As IntPtr
    Public ConstraintType As UInteger
    Public cColumns As UIntPtr
    Public rgColumnList As IntPtr
    Public pReferencedTableID As IntPtr
    Public cForeignKeyColumns As UIntPtr
    Public rgForeignKeyColumnList As IntPtr
    Public pwszConstraintText As IntPtr
    Public UpdateRule As UInteger
    Public DeleteRule As UInteger
    Public MatchType As UInteger
    Public Deferrability As UInteger
    Public cReserved As UIntPtr
    Public rgReserved As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class DBCONSTRAINTDESC(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("pConstraintID", ctypes.c_void_p),
        ("ConstraintType", wintypes.DWORD),
        ("cColumns", ctypes.c_size_t),
        ("rgColumnList", ctypes.c_void_p),
        ("pReferencedTableID", ctypes.c_void_p),
        ("cForeignKeyColumns", ctypes.c_size_t),
        ("rgForeignKeyColumnList", ctypes.c_void_p),
        ("pwszConstraintText", ctypes.c_void_p),
        ("UpdateRule", wintypes.DWORD),
        ("DeleteRule", wintypes.DWORD),
        ("MatchType", wintypes.DWORD),
        ("Deferrability", wintypes.DWORD),
        ("cReserved", ctypes.c_size_t),
        ("rgReserved", ctypes.c_void_p),
    ]
#[repr(C, packed(2))]
pub struct DBCONSTRAINTDESC {
    pub pConstraintID: *mut core::ffi::c_void,
    pub ConstraintType: u32,
    pub cColumns: usize,
    pub rgColumnList: *mut core::ffi::c_void,
    pub pReferencedTableID: *mut core::ffi::c_void,
    pub cForeignKeyColumns: usize,
    pub rgForeignKeyColumnList: *mut core::ffi::c_void,
    pub pwszConstraintText: *mut core::ffi::c_void,
    pub UpdateRule: u32,
    pub DeleteRule: u32,
    pub MatchType: u32,
    pub Deferrability: u32,
    pub cReserved: usize,
    pub rgReserved: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type DBCONSTRAINTDESC struct {
	pConstraintID uintptr
	ConstraintType uint32
	cColumns uintptr
	rgColumnList uintptr
	pReferencedTableID uintptr
	cForeignKeyColumns uintptr
	rgForeignKeyColumnList uintptr
	pwszConstraintText uintptr
	UpdateRule uint32
	DeleteRule uint32
	MatchType uint32
	Deferrability uint32
	cReserved uintptr
	rgReserved uintptr
}
type
  DBCONSTRAINTDESC = packed record
    pConstraintID: Pointer;
    ConstraintType: DWORD;
    cColumns: NativeUInt;
    rgColumnList: Pointer;
    pReferencedTableID: Pointer;
    cForeignKeyColumns: NativeUInt;
    rgForeignKeyColumnList: Pointer;
    pwszConstraintText: Pointer;
    UpdateRule: DWORD;
    DeleteRule: DWORD;
    MatchType: DWORD;
    Deferrability: DWORD;
    cReserved: NativeUInt;
    rgReserved: Pointer;
  end;
const DBCONSTRAINTDESC = extern struct {
    pConstraintID: ?*anyopaque,
    ConstraintType: u32,
    cColumns: usize,
    rgColumnList: ?*anyopaque,
    pReferencedTableID: ?*anyopaque,
    cForeignKeyColumns: usize,
    rgForeignKeyColumnList: ?*anyopaque,
    pwszConstraintText: ?*anyopaque,
    UpdateRule: u32,
    DeleteRule: u32,
    MatchType: u32,
    Deferrability: u32,
    cReserved: usize,
    rgReserved: ?*anyopaque,
};
type
  DBCONSTRAINTDESC {.packed.} = object
    pConstraintID: pointer
    ConstraintType: uint32
    cColumns: uint
    rgColumnList: pointer
    pReferencedTableID: pointer
    cForeignKeyColumns: uint
    rgForeignKeyColumnList: pointer
    pwszConstraintText: pointer
    UpdateRule: uint32
    DeleteRule: uint32
    MatchType: uint32
    Deferrability: uint32
    cReserved: uint
    rgReserved: pointer
align(2)
struct DBCONSTRAINTDESC
{
    void* pConstraintID;
    uint ConstraintType;
    size_t cColumns;
    void* rgColumnList;
    void* pReferencedTableID;
    size_t cForeignKeyColumns;
    void* rgForeignKeyColumnList;
    void* pwszConstraintText;
    uint UpdateRule;
    uint DeleteRule;
    uint MatchType;
    uint Deferrability;
    size_t cReserved;
    void* rgReserved;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DBCONSTRAINTDESC サイズ: 56 バイト(x86)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; pConstraintID : DBID* (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; ConstraintType : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; cColumns : UINT_PTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; rgColumnList : DBID* (+12, 4byte)  varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; pReferencedTableID : DBID* (+16, 4byte)  varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; cForeignKeyColumns : UINT_PTR (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; rgForeignKeyColumnList : DBID* (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; pwszConstraintText : LPWSTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; UpdateRule : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; DeleteRule : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; MatchType : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; Deferrability : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; cReserved : UINT_PTR (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; rgReserved : DBPROPSET* (+52, 4byte)  varptr(st)+52 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DBCONSTRAINTDESC サイズ: 92 バイト(x64)
dim st, 23    ; 4byte整数×23(構造体サイズ 92 / 4 切り上げ)
; pConstraintID : DBID* (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ConstraintType : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; cColumns : UINT_PTR (+12, 8byte)  qpoke st,12,値 / qpeek(st,12)  ※IronHSPのみ。3.7/3.8は lpoke st,12,下位 : lpoke st,16,上位
; rgColumnList : DBID* (+20, 8byte)  varptr(st)+20 を基点に操作(8byte:入れ子/配列)
; pReferencedTableID : DBID* (+28, 8byte)  varptr(st)+28 を基点に操作(8byte:入れ子/配列)
; cForeignKeyColumns : UINT_PTR (+36, 8byte)  qpoke st,36,値 / qpeek(st,36)  ※IronHSPのみ。3.7/3.8は lpoke st,36,下位 : lpoke st,40,上位
; rgForeignKeyColumnList : DBID* (+44, 8byte)  varptr(st)+44 を基点に操作(8byte:入れ子/配列)
; pwszConstraintText : LPWSTR (+52, 8byte)  qpoke st,52,値 / qpeek(st,52)  ※IronHSPのみ。3.7/3.8は lpoke st,52,下位 : lpoke st,56,上位
; UpdateRule : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; DeleteRule : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; MatchType : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; Deferrability : DWORD (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; cReserved : UINT_PTR (+76, 8byte)  qpoke st,76,値 / qpeek(st,76)  ※IronHSPのみ。3.7/3.8は lpoke st,76,下位 : lpoke st,80,上位
; rgReserved : DBPROPSET* (+84, 8byte)  varptr(st)+84 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DBCONSTRAINTDESC, pack=2
    #field intptr pConstraintID
    #field int ConstraintType
    #field intptr cColumns
    #field intptr rgColumnList
    #field intptr pReferencedTableID
    #field intptr cForeignKeyColumns
    #field intptr rgForeignKeyColumnList
    #field intptr pwszConstraintText
    #field int UpdateRule
    #field int DeleteRule
    #field int MatchType
    #field int Deferrability
    #field intptr cReserved
    #field intptr rgReserved
#endstruct

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