ホーム › System.Com › TYPEATTR
TYPEATTR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| guid | GUID | 16 | +0 | +0 | この型のGUID。 |
| lcid | DWORD | 4 | +16 | +16 | 型情報のロケールID。 |
| dwReserved | DWORD | 4 | +20 | +20 | 予約済みフィールド。 |
| memidConstructor | INT | 4 | +24 | +24 | コンストラクタのメンバID。なければMEMBERID_NIL。 |
| memidDestructor | INT | 4 | +28 | +28 | デストラクタのメンバID。なければMEMBERID_NIL。 |
| lpstrSchema | LPWSTR | 8/4 | +32 | +32 | 予約済みのスキーマ文字列。 |
| cbSizeInstance | DWORD | 4 | +40 | +36 | この型のインスタンス1個分のバイトサイズ。 |
| typekind | TYPEKIND | 4 | +44 | +40 | 型の種別(TKIND_ENUM/RECORD/INTERFACE等)。 |
| cFuncs | WORD | 2 | +48 | +44 | メンバ関数の数。 |
| cVars | WORD | 2 | +50 | +46 | メンバ変数の数。 |
| cImplTypes | WORD | 2 | +52 | +48 | 実装/継承するインターフェイスの数。 |
| cbSizeVft | WORD | 2 | +54 | +50 | 仮想関数テーブルのバイトサイズ。 |
| cbAlignment | WORD | 2 | +56 | +52 | メンバ配置のアライメント(バイト)。 |
| wTypeFlags | WORD | 2 | +58 | +54 | 型の属性フラグ(TYPEFLAG_系)。 |
| wMajorVerNum | WORD | 2 | +60 | +56 | 型のメジャーバージョン番号。 |
| wMinorVerNum | WORD | 2 | +62 | +58 | 型のマイナーバージョン番号。 |
| tdescAlias | TYPEDESC | 16/8 | +64 | +60 | TKIND_ALIASの場合の別名先の型(TYPEDESC)。 |
| idldescType | IDLDESC | 16/8 | +80 | +68 | 型に関するIDL属性(IDLDESC)。 |
各言語での定義
#include <windows.h>
// TYPEDESC (x64 16 / x86 8 バイト)
typedef struct TYPEDESC {
_Anonymous_e__Union Anonymous;
VARENUM vt;
} TYPEDESC;
// IDLDESC (x64 16 / x86 8 バイト)
typedef struct IDLDESC {
UINT_PTR dwReserved;
IDLFLAGS wIDLFlags;
} IDLDESC;
// TYPEATTR (x64 96 / x86 76 バイト)
typedef struct TYPEATTR {
GUID guid;
DWORD lcid;
DWORD dwReserved;
INT memidConstructor;
INT memidDestructor;
LPWSTR lpstrSchema;
DWORD cbSizeInstance;
TYPEKIND typekind;
WORD cFuncs;
WORD cVars;
WORD cImplTypes;
WORD cbSizeVft;
WORD cbAlignment;
WORD wTypeFlags;
WORD wMajorVerNum;
WORD wMinorVerNum;
TYPEDESC tdescAlias;
IDLDESC idldescType;
} TYPEATTR;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TYPEDESC
{
public _Anonymous_e__Union Anonymous;
public ushort vt;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IDLDESC
{
public UIntPtr dwReserved;
public ushort wIDLFlags;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TYPEATTR
{
public Guid guid;
public uint lcid;
public uint dwReserved;
public int memidConstructor;
public int memidDestructor;
public IntPtr lpstrSchema;
public uint cbSizeInstance;
public int typekind;
public ushort cFuncs;
public ushort cVars;
public ushort cImplTypes;
public ushort cbSizeVft;
public ushort cbAlignment;
public ushort wTypeFlags;
public ushort wMajorVerNum;
public ushort wMinorVerNum;
public TYPEDESC tdescAlias;
public IDLDESC idldescType;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TYPEDESC
Public Anonymous As _Anonymous_e__Union
Public vt As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IDLDESC
Public dwReserved As UIntPtr
Public wIDLFlags As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TYPEATTR
Public guid As Guid
Public lcid As UInteger
Public dwReserved As UInteger
Public memidConstructor As Integer
Public memidDestructor As Integer
Public lpstrSchema As IntPtr
Public cbSizeInstance As UInteger
Public typekind As Integer
Public cFuncs As UShort
Public cVars As UShort
Public cImplTypes As UShort
Public cbSizeVft As UShort
Public cbAlignment As UShort
Public wTypeFlags As UShort
Public wMajorVerNum As UShort
Public wMinorVerNum As UShort
Public tdescAlias As TYPEDESC
Public idldescType As IDLDESC
End Structureimport ctypes
from ctypes import wintypes
class TYPEDESC(ctypes.Structure):
_fields_ = [
("Anonymous", _Anonymous_e__Union),
("vt", ctypes.c_ushort),
]
class IDLDESC(ctypes.Structure):
_fields_ = [
("dwReserved", ctypes.c_size_t),
("wIDLFlags", ctypes.c_ushort),
]
class TYPEATTR(ctypes.Structure):
_fields_ = [
("guid", GUID),
("lcid", wintypes.DWORD),
("dwReserved", wintypes.DWORD),
("memidConstructor", ctypes.c_int),
("memidDestructor", ctypes.c_int),
("lpstrSchema", ctypes.c_void_p),
("cbSizeInstance", wintypes.DWORD),
("typekind", ctypes.c_int),
("cFuncs", ctypes.c_ushort),
("cVars", ctypes.c_ushort),
("cImplTypes", ctypes.c_ushort),
("cbSizeVft", ctypes.c_ushort),
("cbAlignment", ctypes.c_ushort),
("wTypeFlags", ctypes.c_ushort),
("wMajorVerNum", ctypes.c_ushort),
("wMinorVerNum", ctypes.c_ushort),
("tdescAlias", TYPEDESC),
("idldescType", IDLDESC),
]#[repr(C)]
pub struct TYPEDESC {
pub Anonymous: _Anonymous_e__Union,
pub vt: u16,
}
#[repr(C)]
pub struct IDLDESC {
pub dwReserved: usize,
pub wIDLFlags: u16,
}
#[repr(C)]
pub struct TYPEATTR {
pub guid: GUID,
pub lcid: u32,
pub dwReserved: u32,
pub memidConstructor: i32,
pub memidDestructor: i32,
pub lpstrSchema: *mut core::ffi::c_void,
pub cbSizeInstance: u32,
pub typekind: i32,
pub cFuncs: u16,
pub cVars: u16,
pub cImplTypes: u16,
pub cbSizeVft: u16,
pub cbAlignment: u16,
pub wTypeFlags: u16,
pub wMajorVerNum: u16,
pub wMinorVerNum: u16,
pub tdescAlias: TYPEDESC,
pub idldescType: IDLDESC,
}import "golang.org/x/sys/windows"
type TYPEDESC struct {
Anonymous _Anonymous_e__Union
vt uint16
}
type IDLDESC struct {
dwReserved uintptr
wIDLFlags uint16
}
type TYPEATTR struct {
guid windows.GUID
lcid uint32
dwReserved uint32
memidConstructor int32
memidDestructor int32
lpstrSchema uintptr
cbSizeInstance uint32
typekind int32
cFuncs uint16
cVars uint16
cImplTypes uint16
cbSizeVft uint16
cbAlignment uint16
wTypeFlags uint16
wMajorVerNum uint16
wMinorVerNum uint16
tdescAlias TYPEDESC
idldescType IDLDESC
}type
TYPEDESC = record
Anonymous: _Anonymous_e__Union;
vt: Word;
end;
IDLDESC = record
dwReserved: NativeUInt;
wIDLFlags: Word;
end;
TYPEATTR = record
guid: TGUID;
lcid: DWORD;
dwReserved: DWORD;
memidConstructor: Integer;
memidDestructor: Integer;
lpstrSchema: Pointer;
cbSizeInstance: DWORD;
typekind: Integer;
cFuncs: Word;
cVars: Word;
cImplTypes: Word;
cbSizeVft: Word;
cbAlignment: Word;
wTypeFlags: Word;
wMajorVerNum: Word;
wMinorVerNum: Word;
tdescAlias: TYPEDESC;
idldescType: IDLDESC;
end;const TYPEDESC = extern struct {
Anonymous: _Anonymous_e__Union,
vt: u16,
};
const IDLDESC = extern struct {
dwReserved: usize,
wIDLFlags: u16,
};
const TYPEATTR = extern struct {
guid: GUID,
lcid: u32,
dwReserved: u32,
memidConstructor: i32,
memidDestructor: i32,
lpstrSchema: ?*anyopaque,
cbSizeInstance: u32,
typekind: i32,
cFuncs: u16,
cVars: u16,
cImplTypes: u16,
cbSizeVft: u16,
cbAlignment: u16,
wTypeFlags: u16,
wMajorVerNum: u16,
wMinorVerNum: u16,
tdescAlias: TYPEDESC,
idldescType: IDLDESC,
};type
TYPEDESC {.bycopy.} = object
Anonymous: _Anonymous_e__Union
vt: uint16
IDLDESC {.bycopy.} = object
dwReserved: uint
wIDLFlags: uint16
TYPEATTR {.bycopy.} = object
guid: GUID
lcid: uint32
dwReserved: uint32
memidConstructor: int32
memidDestructor: int32
lpstrSchema: pointer
cbSizeInstance: uint32
typekind: int32
cFuncs: uint16
cVars: uint16
cImplTypes: uint16
cbSizeVft: uint16
cbAlignment: uint16
wTypeFlags: uint16
wMajorVerNum: uint16
wMinorVerNum: uint16
tdescAlias: TYPEDESC
idldescType: IDLDESCstruct TYPEDESC
{
_Anonymous_e__Union Anonymous;
ushort vt;
}
struct IDLDESC
{
size_t dwReserved;
ushort wIDLFlags;
}
struct TYPEATTR
{
GUID guid;
uint lcid;
uint dwReserved;
int memidConstructor;
int memidDestructor;
void* lpstrSchema;
uint cbSizeInstance;
int typekind;
ushort cFuncs;
ushort cVars;
ushort cImplTypes;
ushort cbSizeVft;
ushort cbAlignment;
ushort wTypeFlags;
ushort wMajorVerNum;
ushort wMinorVerNum;
TYPEDESC tdescAlias;
IDLDESC idldescType;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; TYPEATTR サイズ: 76 バイト(x86)
dim st, 19 ; 4byte整数×19(構造体サイズ 76 / 4 切り上げ)
; guid : GUID (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; lcid : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; dwReserved : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; memidConstructor : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; memidDestructor : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; lpstrSchema : LPWSTR (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; cbSizeInstance : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; typekind : TYPEKIND (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; cFuncs : WORD (+44, 2byte) wpoke st,44,値 / 値 = wpeek(st,44)
; cVars : WORD (+46, 2byte) wpoke st,46,値 / 値 = wpeek(st,46)
; cImplTypes : WORD (+48, 2byte) wpoke st,48,値 / 値 = wpeek(st,48)
; cbSizeVft : WORD (+50, 2byte) wpoke st,50,値 / 値 = wpeek(st,50)
; cbAlignment : WORD (+52, 2byte) wpoke st,52,値 / 値 = wpeek(st,52)
; wTypeFlags : WORD (+54, 2byte) wpoke st,54,値 / 値 = wpeek(st,54)
; wMajorVerNum : WORD (+56, 2byte) wpoke st,56,値 / 値 = wpeek(st,56)
; wMinorVerNum : WORD (+58, 2byte) wpoke st,58,値 / 値 = wpeek(st,58)
; tdescAlias : TYPEDESC (+60, 8byte) varptr(st)+60 を基点に操作(8byte:入れ子/配列)
; idldescType : IDLDESC (+68, 8byte) varptr(st)+68 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TYPEATTR サイズ: 96 バイト(x64)
dim st, 24 ; 4byte整数×24(構造体サイズ 96 / 4 切り上げ)
; guid : GUID (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; lcid : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; dwReserved : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; memidConstructor : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; memidDestructor : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; lpstrSchema : LPWSTR (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; cbSizeInstance : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; typekind : TYPEKIND (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; cFuncs : WORD (+48, 2byte) wpoke st,48,値 / 値 = wpeek(st,48)
; cVars : WORD (+50, 2byte) wpoke st,50,値 / 値 = wpeek(st,50)
; cImplTypes : WORD (+52, 2byte) wpoke st,52,値 / 値 = wpeek(st,52)
; cbSizeVft : WORD (+54, 2byte) wpoke st,54,値 / 値 = wpeek(st,54)
; cbAlignment : WORD (+56, 2byte) wpoke st,56,値 / 値 = wpeek(st,56)
; wTypeFlags : WORD (+58, 2byte) wpoke st,58,値 / 値 = wpeek(st,58)
; wMajorVerNum : WORD (+60, 2byte) wpoke st,60,値 / 値 = wpeek(st,60)
; wMinorVerNum : WORD (+62, 2byte) wpoke st,62,値 / 値 = wpeek(st,62)
; tdescAlias : TYPEDESC (+64, 16byte) varptr(st)+64 を基点に操作(16byte:入れ子/配列)
; idldescType : IDLDESC (+80, 16byte) varptr(st)+80 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global TYPEDESC
#field byte Anonymous 8
#field short vt
#endstruct
#defstruct global IDLDESC
#field intptr dwReserved
#field short wIDLFlags
#endstruct
#defstruct global TYPEATTR
#field GUID guid
#field int lcid
#field int dwReserved
#field int memidConstructor
#field int memidDestructor
#field intptr lpstrSchema
#field int cbSizeInstance
#field int typekind
#field short cFuncs
#field short cVars
#field short cImplTypes
#field short cbSizeVft
#field short cbAlignment
#field short wTypeFlags
#field short wMajorVerNum
#field short wMinorVerNum
#field TYPEDESC tdescAlias
#field IDLDESC idldescType
#endstruct
stdim st, TYPEATTR ; NSTRUCT 変数を確保
st->lcid = 100
mes "lcid=" + st->lcid