ホーム › System.Com › FORMATETC
FORMATETC
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cfFormat | WORD | 2 | +0 | +0 | クリップボード形式を示すフォーマット値。 |
| ptd | DVTARGETDEVICE* | 8/4 | +8 | +4 | 対象デバイス情報(DVTARGETDEVICE)へのポインタ。NULL可。 |
| dwAspect | DWORD | 4 | +16 | +8 | データの表示観点(DVASPECT_CONTENT等)。 |
| lindex | INT | 4 | +20 | +12 | 取得するデータの一部を示すインデックス。通常-1。 |
| tymed | DWORD | 4 | +24 | +16 | データの格納媒体種別(TYMED_HGLOBAL等)。 |
各言語での定義
#include <windows.h>
// FORMATETC (x64 32 / x86 20 バイト)
typedef struct FORMATETC {
WORD cfFormat;
DVTARGETDEVICE* ptd;
DWORD dwAspect;
INT lindex;
DWORD tymed;
} FORMATETC;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;
}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 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),
]#[repr(C)]
pub struct FORMATETC {
pub cfFormat: u16,
pub ptd: *mut core::ffi::c_void,
pub dwAspect: u32,
pub lindex: i32,
pub tymed: u32,
}import "golang.org/x/sys/windows"
type FORMATETC struct {
cfFormat uint16
ptd uintptr
dwAspect uint32
lindex int32
tymed uint32
}type
FORMATETC = record
cfFormat: Word;
ptd: Pointer;
dwAspect: DWORD;
lindex: Integer;
tymed: DWORD;
end;const FORMATETC = extern struct {
cfFormat: u16,
ptd: ?*anyopaque,
dwAspect: u32,
lindex: i32,
tymed: u32,
};type
FORMATETC {.bycopy.} = object
cfFormat: uint16
ptd: pointer
dwAspect: uint32
lindex: int32
tymed: uint32struct FORMATETC
{
ushort cfFormat;
void* ptd;
uint dwAspect;
int lindex;
uint tymed;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; FORMATETC サイズ: 20 バイト(x86)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; cfFormat : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; ptd : DVTARGETDEVICE* (+4, 4byte) varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; dwAspect : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lindex : INT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; tymed : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; FORMATETC サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; cfFormat : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; ptd : DVTARGETDEVICE* (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; dwAspect : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; lindex : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; tymed : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global FORMATETC
#field short cfFormat
#field intptr ptd
#field int dwAspect
#field int lindex
#field int tymed
#endstruct
stdim st, FORMATETC ; NSTRUCT 変数を確保
st->cfFormat = 100
mes "cfFormat=" + st->cfFormat