Win32 API 日本語リファレンス
ホームSystem.Console › ExtKeyDefBuf

ExtKeyDefBuf

構造体
サイズx64: 476 バイト / x86: 476 バイトパッキング2

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

フィールド

フィールドサイズx64x86説明
dwVersionDWORD4+0+0拡張キー定義テーブルのバージョン番号。
dwCheckSumDWORD4+4+4テーブルの整合性検証用チェックサム。
tableExtKeyDef468+8+8拡張キー定義の本体(ExtKeyDef)。

各言語での定義

#include <windows.h>

// ExtKeySubst  (x64 6 / x86 6 バイト)
typedef struct ExtKeySubst {
    WORD wMod;
    WORD wVirKey;
    WCHAR wUnicodeChar;
} ExtKeySubst;

// ExtKeyDef  (x64 18 / x86 18 バイト)
typedef struct ExtKeyDef {
    ExtKeySubst keys[3];
} ExtKeyDef;

// ExtKeyDefBuf  (x64 476 / x86 476 バイト)
#pragma pack(push, 2)
typedef struct ExtKeyDefBuf {
    DWORD dwVersion;
    DWORD dwCheckSum;
    ExtKeyDef table[26];
} ExtKeyDefBuf;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ExtKeySubst
{
    public ushort wMod;
    public ushort wVirKey;
    public char wUnicodeChar;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ExtKeyDef
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public ExtKeySubst[] keys;
}

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct ExtKeyDefBuf
{
    public uint dwVersion;
    public uint dwCheckSum;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 26)] public ExtKeyDef[] table;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ExtKeySubst
    Public wMod As UShort
    Public wVirKey As UShort
    Public wUnicodeChar As Char
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ExtKeyDef
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public keys() As ExtKeySubst
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure ExtKeyDefBuf
    Public dwVersion As UInteger
    Public dwCheckSum As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=26)> Public table() As ExtKeyDef
End Structure
import ctypes
from ctypes import wintypes

class ExtKeySubst(ctypes.Structure):
    _fields_ = [
        ("wMod", ctypes.c_ushort),
        ("wVirKey", ctypes.c_ushort),
        ("wUnicodeChar", ctypes.c_wchar),
    ]

class ExtKeyDef(ctypes.Structure):
    _fields_ = [
        ("keys", ExtKeySubst * 3),
    ]

class ExtKeyDefBuf(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("dwVersion", wintypes.DWORD),
        ("dwCheckSum", wintypes.DWORD),
        ("table", ExtKeyDef * 26),
    ]
#[repr(C)]
pub struct ExtKeySubst {
    pub wMod: u16,
    pub wVirKey: u16,
    pub wUnicodeChar: u16,
}

#[repr(C)]
pub struct ExtKeyDef {
    pub keys: [ExtKeySubst; 3],
}

#[repr(C, packed(2))]
pub struct ExtKeyDefBuf {
    pub dwVersion: u32,
    pub dwCheckSum: u32,
    pub table: [ExtKeyDef; 26],
}
import "golang.org/x/sys/windows"

type ExtKeySubst struct {
	wMod uint16
	wVirKey uint16
	wUnicodeChar uint16
}

type ExtKeyDef struct {
	keys [3]ExtKeySubst
}

type ExtKeyDefBuf struct {
	dwVersion uint32
	dwCheckSum uint32
	table [26]ExtKeyDef
}
type
  ExtKeySubst = record
    wMod: Word;
    wVirKey: Word;
    wUnicodeChar: WideChar;
  end;

  ExtKeyDef = record
    keys: array[0..2] of ExtKeySubst;
  end;

  ExtKeyDefBuf = packed record
    dwVersion: DWORD;
    dwCheckSum: DWORD;
    table: array[0..25] of ExtKeyDef;
  end;
const ExtKeySubst = extern struct {
    wMod: u16,
    wVirKey: u16,
    wUnicodeChar: u16,
};

const ExtKeyDef = extern struct {
    keys: [3]ExtKeySubst,
};

const ExtKeyDefBuf = extern struct {
    dwVersion: u32,
    dwCheckSum: u32,
    table: [26]ExtKeyDef,
};
type
  ExtKeySubst {.bycopy.} = object
    wMod: uint16
    wVirKey: uint16
    wUnicodeChar: uint16

  ExtKeyDef {.bycopy.} = object
    keys: array[3, ExtKeySubst]

  ExtKeyDefBuf {.packed.} = object
    dwVersion: uint32
    dwCheckSum: uint32
    table: array[26, ExtKeyDef]
struct ExtKeySubst
{
    ushort wMod;
    ushort wVirKey;
    wchar wUnicodeChar;
}

struct ExtKeyDef
{
    ExtKeySubst[3] keys;
}

align(2)
struct ExtKeyDefBuf
{
    uint dwVersion;
    uint dwCheckSum;
    ExtKeyDef[26] table;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ExtKeyDefBuf サイズ: 476 バイト(x64)
dim st, 119    ; 4byte整数×119(構造体サイズ 476 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwCheckSum : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; table : ExtKeyDef (+8, 468byte)  varptr(st)+8 を基点に操作(468byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global ExtKeySubst
    #field short wMod
    #field short wVirKey
    #field short wUnicodeChar
#endstruct

#defstruct global ExtKeyDef
    #field ExtKeySubst keys 3
#endstruct

#defstruct global ExtKeyDefBuf, pack=2
    #field int dwVersion
    #field int dwCheckSum
    #field ExtKeyDef table 26
#endstruct

stdim st, ExtKeyDefBuf        ; NSTRUCT 変数を確保
st->dwVersion = 100
mes "dwVersion=" + st->dwVersion