Win32 API 日本語リファレンス
ホームUI.Input.Ime › IMEWRD

IMEWRD

構造体
サイズx64: 48 バイト / x86: 32 バイトパッキング1

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
pwchReadingLPWSTR8/4+0+0単語の読み文字列へのポインタである。
pwchDisplayLPWSTR8/4+8+4単語の表示文字列へのポインタである。
Anonymous_Anonymous_e__Union8/4+16+8品詞や属性を保持する無名共用体である。
rgulAttrsDWORD8+24+12単語の属性ビット配列である。
cbCommentINT4+32+20コメントデータのバイト数である。
uctIMEUCT4+36+24コメントの種別を示すIMEUCT値である。
pvCommentvoid*8/4+40+28コメントデータへのポインタである。

共用体: _Anonymous_e__Union x64 8B / x86 4B

フィールドサイズx64x86説明
ulPosDWORD4+0+0
Anonymous_Anonymous_e__Struct8/4+0+0品詞や属性を保持する無名共用体である。

各言語での定義

#include <windows.h>

// IMEWRD  (x64 48 / x86 32 バイト)
#pragma pack(push, 1)
typedef struct IMEWRD {
    LPWSTR pwchReading;
    LPWSTR pwchDisplay;
    _Anonymous_e__Union Anonymous;
    DWORD rgulAttrs[2];
    INT cbComment;
    IMEUCT uct;
    void* pvComment;
} IMEWRD;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct IMEWRD
{
    public IntPtr pwchReading;
    public IntPtr pwchDisplay;
    public _Anonymous_e__Union Anonymous;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] rgulAttrs;
    public int cbComment;
    public int uct;
    public IntPtr pvComment;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure IMEWRD
    Public pwchReading As IntPtr
    Public pwchDisplay As IntPtr
    Public Anonymous As _Anonymous_e__Union
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public rgulAttrs() As UInteger
    Public cbComment As Integer
    Public uct As Integer
    Public pvComment As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class IMEWRD(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("pwchReading", ctypes.c_void_p),
        ("pwchDisplay", ctypes.c_void_p),
        ("Anonymous", _Anonymous_e__Union),
        ("rgulAttrs", wintypes.DWORD * 2),
        ("cbComment", ctypes.c_int),
        ("uct", ctypes.c_int),
        ("pvComment", ctypes.c_void_p),
    ]
#[repr(C, packed(1))]
pub struct IMEWRD {
    pub pwchReading: *mut core::ffi::c_void,
    pub pwchDisplay: *mut core::ffi::c_void,
    pub Anonymous: _Anonymous_e__Union,
    pub rgulAttrs: [u32; 2],
    pub cbComment: i32,
    pub uct: i32,
    pub pvComment: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type IMEWRD struct {
	pwchReading uintptr
	pwchDisplay uintptr
	Anonymous _Anonymous_e__Union
	rgulAttrs [2]uint32
	cbComment int32
	uct int32
	pvComment uintptr
}
type
  IMEWRD = packed record
    pwchReading: Pointer;
    pwchDisplay: Pointer;
    Anonymous: _Anonymous_e__Union;
    rgulAttrs: array[0..1] of DWORD;
    cbComment: Integer;
    uct: Integer;
    pvComment: Pointer;
  end;
const IMEWRD = extern struct {
    pwchReading: ?*anyopaque,
    pwchDisplay: ?*anyopaque,
    Anonymous: _Anonymous_e__Union,
    rgulAttrs: [2]u32,
    cbComment: i32,
    uct: i32,
    pvComment: ?*anyopaque,
};
type
  IMEWRD {.packed.} = object
    pwchReading: pointer
    pwchDisplay: pointer
    Anonymous: _Anonymous_e__Union
    rgulAttrs: array[2, uint32]
    cbComment: int32
    uct: int32
    pvComment: pointer
align(1)
struct IMEWRD
{
    void* pwchReading;
    void* pwchDisplay;
    _Anonymous_e__Union Anonymous;
    uint[2] rgulAttrs;
    int cbComment;
    int uct;
    void* pvComment;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; IMEWRD サイズ: 32 バイト(x86)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; pwchReading : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pwchDisplay : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; rgulAttrs : DWORD (+12, 8byte)  varptr(st)+12 を基点に操作(8byte:入れ子/配列)
; cbComment : INT (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; uct : IMEUCT (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; pvComment : void* (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IMEWRD サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; pwchReading : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; pwchDisplay : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; Anonymous : _Anonymous_e__Union (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; rgulAttrs : DWORD (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; cbComment : INT (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; uct : IMEUCT (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; pvComment : void* (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IMEWRD, pack=1
    #field intptr pwchReading
    #field intptr pwchDisplay
    #field byte Anonymous 8
    #field int rgulAttrs 2
    #field int cbComment
    #field int uct
    #field intptr pvComment
#endstruct

stdim st, IMEWRD        ; NSTRUCT 変数を確保
st->cbComment = 100
mes "cbComment=" + st->cbComment
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。