ホーム › System.Com › STATDATA
STATDATA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| formatetc | FORMATETC | 32/20 | +0 | +0 | アドバイズ対象のデータ形式(FORMATETC)。 |
| advf | DWORD | 4 | +32 | +20 | アドバイズ動作を制御するフラグ(ADVF系)。 |
| pAdvSink | IAdviseSink* | 8/4 | +40 | +24 | 変更通知を受け取るIAdviseSinkへのポインタ。 |
| dwConnection | DWORD | 4 | +48 | +28 | このアドバイズ接続を識別するトークン。 |
各言語での定義
#include <windows.h>
// FORMATETC (x64 32 / x86 20 バイト)
typedef struct FORMATETC {
WORD cfFormat;
DVTARGETDEVICE* ptd;
DWORD dwAspect;
INT lindex;
DWORD tymed;
} FORMATETC;
// STATDATA (x64 56 / x86 32 バイト)
typedef struct STATDATA {
FORMATETC formatetc;
DWORD advf;
IAdviseSink* pAdvSink;
DWORD dwConnection;
} STATDATA;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FORMATETC
{
public ushort cfFormat;
public IntPtr ptd;
public uint dwAspect;
public int lindex;
public uint tymed;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STATDATA
{
public FORMATETC formatetc;
public uint advf;
public IntPtr pAdvSink;
public uint dwConnection;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FORMATETC
Public cfFormat As UShort
Public ptd As IntPtr
Public dwAspect As UInteger
Public lindex As Integer
Public tymed As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STATDATA
Public formatetc As FORMATETC
Public advf As UInteger
Public pAdvSink As IntPtr
Public dwConnection As UInteger
End Structureimport ctypes
from ctypes import wintypes
class FORMATETC(ctypes.Structure):
_fields_ = [
("cfFormat", ctypes.c_ushort),
("ptd", ctypes.c_void_p),
("dwAspect", wintypes.DWORD),
("lindex", ctypes.c_int),
("tymed", wintypes.DWORD),
]
class STATDATA(ctypes.Structure):
_fields_ = [
("formatetc", FORMATETC),
("advf", wintypes.DWORD),
("pAdvSink", ctypes.c_void_p),
("dwConnection", wintypes.DWORD),
]#[repr(C)]
pub struct FORMATETC {
pub cfFormat: u16,
pub ptd: *mut core::ffi::c_void,
pub dwAspect: u32,
pub lindex: i32,
pub tymed: u32,
}
#[repr(C)]
pub struct STATDATA {
pub formatetc: FORMATETC,
pub advf: u32,
pub pAdvSink: *mut core::ffi::c_void,
pub dwConnection: u32,
}import "golang.org/x/sys/windows"
type FORMATETC struct {
cfFormat uint16
ptd uintptr
dwAspect uint32
lindex int32
tymed uint32
}
type STATDATA struct {
formatetc FORMATETC
advf uint32
pAdvSink uintptr
dwConnection uint32
}type
FORMATETC = record
cfFormat: Word;
ptd: Pointer;
dwAspect: DWORD;
lindex: Integer;
tymed: DWORD;
end;
STATDATA = record
formatetc: FORMATETC;
advf: DWORD;
pAdvSink: Pointer;
dwConnection: DWORD;
end;const FORMATETC = extern struct {
cfFormat: u16,
ptd: ?*anyopaque,
dwAspect: u32,
lindex: i32,
tymed: u32,
};
const STATDATA = extern struct {
formatetc: FORMATETC,
advf: u32,
pAdvSink: ?*anyopaque,
dwConnection: u32,
};type
FORMATETC {.bycopy.} = object
cfFormat: uint16
ptd: pointer
dwAspect: uint32
lindex: int32
tymed: uint32
STATDATA {.bycopy.} = object
formatetc: FORMATETC
advf: uint32
pAdvSink: pointer
dwConnection: uint32struct FORMATETC
{
ushort cfFormat;
void* ptd;
uint dwAspect;
int lindex;
uint tymed;
}
struct STATDATA
{
FORMATETC formatetc;
uint advf;
void* pAdvSink;
uint dwConnection;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; STATDATA サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; formatetc : FORMATETC (+0, 20byte) varptr(st)+0 を基点に操作(20byte:入れ子/配列)
; advf : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; pAdvSink : IAdviseSink* (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; dwConnection : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STATDATA サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; formatetc : FORMATETC (+0, 32byte) varptr(st)+0 を基点に操作(32byte:入れ子/配列)
; advf : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; pAdvSink : IAdviseSink* (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; dwConnection : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global FORMATETC
#field short cfFormat
#field intptr ptd
#field int dwAspect
#field int lindex
#field int tymed
#endstruct
#defstruct global STATDATA
#field FORMATETC formatetc
#field int advf
#field intptr pAdvSink
#field int dwConnection
#endstruct
stdim st, STATDATA ; NSTRUCT 変数を確保
st->advf = 100
mes "advf=" + st->advf