ホーム › Networking.WindowsWebServices › WS_UNION_DESCRIPTION
WS_UNION_DESCRIPTION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| size | DWORD | 4 | +0 | +0 | 共用体全体のサイズ(バイト数)。 |
| alignment | DWORD | 4 | +4 | +4 | 共用体のメモリアライメント(バイト境界)。 |
| fields | WS_UNION_FIELD_DESCRIPTION** | 8/4 | +8 | +8 | 共用体フィールド記述の配列へのポインタ。各要素はメンバ記述へのポインタ。 |
| fieldCount | DWORD | 4 | +16 | +12 | fields配列の要素数。 |
| enumOffset | DWORD | 4 | +20 | +16 | 判別子(列挙)値を格納するフィールドのバイトオフセット。 |
| noneEnumValue | INT | 4 | +24 | +20 | どのメンバも選択されていないことを示す列挙値。 |
| valueIndices | DWORD* | 8/4 | +32 | +24 | 判別子値からfields配列への対応を高速化する検索用インデックス配列へのポインタ。 |
各言語での定義
#include <windows.h>
// WS_UNION_DESCRIPTION (x64 40 / x86 28 バイト)
typedef struct WS_UNION_DESCRIPTION {
DWORD size;
DWORD alignment;
WS_UNION_FIELD_DESCRIPTION** fields;
DWORD fieldCount;
DWORD enumOffset;
INT noneEnumValue;
DWORD* valueIndices;
} WS_UNION_DESCRIPTION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_UNION_DESCRIPTION
{
public uint size;
public uint alignment;
public IntPtr fields;
public uint fieldCount;
public uint enumOffset;
public int noneEnumValue;
public IntPtr valueIndices;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_UNION_DESCRIPTION
Public size As UInteger
Public alignment As UInteger
Public fields As IntPtr
Public fieldCount As UInteger
Public enumOffset As UInteger
Public noneEnumValue As Integer
Public valueIndices As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class WS_UNION_DESCRIPTION(ctypes.Structure):
_fields_ = [
("size", wintypes.DWORD),
("alignment", wintypes.DWORD),
("fields", ctypes.c_void_p),
("fieldCount", wintypes.DWORD),
("enumOffset", wintypes.DWORD),
("noneEnumValue", ctypes.c_int),
("valueIndices", ctypes.c_void_p),
]#[repr(C)]
pub struct WS_UNION_DESCRIPTION {
pub size: u32,
pub alignment: u32,
pub fields: *mut core::ffi::c_void,
pub fieldCount: u32,
pub enumOffset: u32,
pub noneEnumValue: i32,
pub valueIndices: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type WS_UNION_DESCRIPTION struct {
size uint32
alignment uint32
fields uintptr
fieldCount uint32
enumOffset uint32
noneEnumValue int32
valueIndices uintptr
}type
WS_UNION_DESCRIPTION = record
size: DWORD;
alignment: DWORD;
fields: Pointer;
fieldCount: DWORD;
enumOffset: DWORD;
noneEnumValue: Integer;
valueIndices: Pointer;
end;const WS_UNION_DESCRIPTION = extern struct {
size: u32,
alignment: u32,
fields: ?*anyopaque,
fieldCount: u32,
enumOffset: u32,
noneEnumValue: i32,
valueIndices: ?*anyopaque,
};type
WS_UNION_DESCRIPTION {.bycopy.} = object
size: uint32
alignment: uint32
fields: pointer
fieldCount: uint32
enumOffset: uint32
noneEnumValue: int32
valueIndices: pointerstruct WS_UNION_DESCRIPTION
{
uint size;
uint alignment;
void* fields;
uint fieldCount;
uint enumOffset;
int noneEnumValue;
void* valueIndices;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WS_UNION_DESCRIPTION サイズ: 28 バイト(x86)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; alignment : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; fields : WS_UNION_FIELD_DESCRIPTION** (+8, 4byte) varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; fieldCount : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; enumOffset : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; noneEnumValue : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; valueIndices : DWORD* (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WS_UNION_DESCRIPTION サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; alignment : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; fields : WS_UNION_FIELD_DESCRIPTION** (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; fieldCount : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; enumOffset : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; noneEnumValue : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; valueIndices : DWORD* (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WS_UNION_DESCRIPTION
#field int size
#field int alignment
#field intptr fields
#field int fieldCount
#field int enumOffset
#field int noneEnumValue
#field intptr valueIndices
#endstruct
stdim st, WS_UNION_DESCRIPTION ; NSTRUCT 変数を確保
st->size = 100
mes "size=" + st->size