XID
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| formatID | INT | 4 | +0 | +0 | X/Openトランザクション識別子のフォーマットID。 |
| gtrid_length | INT | 4 | +4 | +4 | グローバルトランザクションID部分の長さ。単位はバイト。 |
| bqual_length | INT | 4 | +8 | +8 | ブランチ修飾子部分の長さ。単位はバイト。 |
| data | CHAR | 128 | +12 | +12 | gtridとbqualを連結したデータ配列。 |
各言語での定義
#include <windows.h>
// XID (x64 140 / x86 140 バイト)
typedef struct XID {
INT formatID;
INT gtrid_length;
INT bqual_length;
CHAR data[128];
} XID;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct XID
{
public int formatID;
public int gtrid_length;
public int bqual_length;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public sbyte[] data;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure XID
Public formatID As Integer
Public gtrid_length As Integer
Public bqual_length As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=128)> Public data() As SByte
End Structureimport ctypes
from ctypes import wintypes
class XID(ctypes.Structure):
_fields_ = [
("formatID", ctypes.c_int),
("gtrid_length", ctypes.c_int),
("bqual_length", ctypes.c_int),
("data", ctypes.c_byte * 128),
]#[repr(C)]
pub struct XID {
pub formatID: i32,
pub gtrid_length: i32,
pub bqual_length: i32,
pub data: [i8; 128],
}import "golang.org/x/sys/windows"
type XID struct {
formatID int32
gtrid_length int32
bqual_length int32
data [128]int8
}type
XID = record
formatID: Integer;
gtrid_length: Integer;
bqual_length: Integer;
data: array[0..127] of Shortint;
end;const XID = extern struct {
formatID: i32,
gtrid_length: i32,
bqual_length: i32,
data: [128]i8,
};type
XID {.bycopy.} = object
formatID: int32
gtrid_length: int32
bqual_length: int32
data: array[128, int8]struct XID
{
int formatID;
int gtrid_length;
int bqual_length;
byte[128] data;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; XID サイズ: 140 バイト(x64)
dim st, 35 ; 4byte整数×35(構造体サイズ 140 / 4 切り上げ)
; formatID : INT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; gtrid_length : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; bqual_length : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; data : CHAR (+12, 128byte) varptr(st)+12 を基点に操作(128byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global XID
#field int formatID
#field int gtrid_length
#field int bqual_length
#field byte data 128
#endstruct
stdim st, XID ; NSTRUCT 変数を確保
st->formatID = 100
mes "formatID=" + st->formatID