ホーム › System.EventCollector › EC_VARIANT
EC_VARIANT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Anonymous | _Anonymous_e__Union | 8 | +0 | +0 | 型に応じた実データを保持する共用体(数値・文字列・GUID等)。 |
| Count | DWORD | 4 | +8 | +8 | 配列型の場合の要素数。 |
| Type | DWORD | 4 | +12 | +12 | 格納された値の型(EC_VARIANT_TYPE)。 |
共用体: _Anonymous_e__Union x64 8B / x86 8B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| BooleanVal | BOOL | 4 | +0 | +0 |
| UInt32Val | DWORD | 4 | +0 | +0 |
| DateTimeVal | ULONGLONG | 8 | +0 | +0 |
| StringVal | LPWSTR | 8/4 | +0 | +0 |
| BinaryVal | BYTE* | 8/4 | +0 | +0 |
| BooleanArr | BOOL* | 8/4 | +0 | +0 |
| Int32Arr | INT* | 8/4 | +0 | +0 |
| StringArr | LPWSTR* | 8/4 | +0 | +0 |
| PropertyHandleVal | INT_PTR | 8/4 | +0 | +0 |
各言語での定義
#include <windows.h>
// EC_VARIANT (x64 16 / x86 16 バイト)
typedef struct EC_VARIANT {
_Anonymous_e__Union Anonymous;
DWORD Count;
DWORD Type;
} EC_VARIANT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EC_VARIANT
{
public _Anonymous_e__Union Anonymous;
public uint Count;
public uint Type;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EC_VARIANT
Public Anonymous As _Anonymous_e__Union
Public Count As UInteger
Public Type As UInteger
End Structureimport ctypes
from ctypes import wintypes
class EC_VARIANT(ctypes.Structure):
_fields_ = [
("Anonymous", _Anonymous_e__Union),
("Count", wintypes.DWORD),
("Type", wintypes.DWORD),
]#[repr(C)]
pub struct EC_VARIANT {
pub Anonymous: _Anonymous_e__Union,
pub Count: u32,
pub Type: u32,
}import "golang.org/x/sys/windows"
type EC_VARIANT struct {
Anonymous _Anonymous_e__Union
Count uint32
Type uint32
}type
EC_VARIANT = record
Anonymous: _Anonymous_e__Union;
Count: DWORD;
Type: DWORD;
end;const EC_VARIANT = extern struct {
Anonymous: _Anonymous_e__Union,
Count: u32,
Type: u32,
};type
EC_VARIANT {.bycopy.} = object
Anonymous: _Anonymous_e__Union
Count: uint32
Type: uint32struct EC_VARIANT
{
_Anonymous_e__Union Anonymous;
uint Count;
uint Type;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EC_VARIANT サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; Anonymous : _Anonymous_e__Union (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; Count : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; Type : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global EC_VARIANT
#field byte Anonymous 8
#field int Count
#field int Type
#endstruct
stdim st, EC_VARIANT ; NSTRUCT 変数を確保
st->Count = 100
mes "Count=" + st->Count
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。