DEFCONTEXTMENU
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| hwnd | HWND | 8/4 | +0 | +0 | コンテキストメニューの所有者ウィンドウのハンドル。 |
| pcmcb | IContextMenuCB* | 8/4 | +8 | +4 | メニュー動作をカスタマイズする IContextMenuCB コールバック。NULL 可。 |
| pidlFolder | ITEMIDLIST* | 8/4 | +16 | +8 | 対象アイテムが属する親フォルダーのPIDL。NULL 可。 |
| psf | IShellFolder* | 8/4 | +24 | +12 | 対象アイテムを含む IShellFolder へのポインタ。 |
| cidl | DWORD | 4 | +32 | +16 | apidl 配列に含まれるアイテム数。 |
| apidl | ITEMIDLIST** | 8/4 | +40 | +20 | 対象アイテムの相対PIDL配列へのポインタ。 |
| punkAssociationInfo | IUnknown* | 8/4 | +48 | +24 | ファイル関連付け情報を提供するオブジェクト。NULL 可。 |
| cKeys | DWORD | 4 | +56 | +28 | aKeys 配列に含まれるレジストリキーの数。 |
| aKeys | HKEY* | 8/4 | +64 | +32 | 関連付け情報を検索するレジストリキーの配列。 |
各言語での定義
#include <windows.h>
// DEFCONTEXTMENU (x64 72 / x86 36 バイト)
typedef struct DEFCONTEXTMENU {
HWND hwnd;
IContextMenuCB* pcmcb;
ITEMIDLIST* pidlFolder;
IShellFolder* psf;
DWORD cidl;
ITEMIDLIST** apidl;
IUnknown* punkAssociationInfo;
DWORD cKeys;
HKEY* aKeys;
} DEFCONTEXTMENU;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DEFCONTEXTMENU
{
public IntPtr hwnd;
public IntPtr pcmcb;
public IntPtr pidlFolder;
public IntPtr psf;
public uint cidl;
public IntPtr apidl;
public IntPtr punkAssociationInfo;
public uint cKeys;
public IntPtr aKeys;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DEFCONTEXTMENU
Public hwnd As IntPtr
Public pcmcb As IntPtr
Public pidlFolder As IntPtr
Public psf As IntPtr
Public cidl As UInteger
Public apidl As IntPtr
Public punkAssociationInfo As IntPtr
Public cKeys As UInteger
Public aKeys As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class DEFCONTEXTMENU(ctypes.Structure):
_fields_ = [
("hwnd", ctypes.c_void_p),
("pcmcb", ctypes.c_void_p),
("pidlFolder", ctypes.c_void_p),
("psf", ctypes.c_void_p),
("cidl", wintypes.DWORD),
("apidl", ctypes.c_void_p),
("punkAssociationInfo", ctypes.c_void_p),
("cKeys", wintypes.DWORD),
("aKeys", ctypes.c_void_p),
]#[repr(C)]
pub struct DEFCONTEXTMENU {
pub hwnd: *mut core::ffi::c_void,
pub pcmcb: *mut core::ffi::c_void,
pub pidlFolder: *mut core::ffi::c_void,
pub psf: *mut core::ffi::c_void,
pub cidl: u32,
pub apidl: *mut core::ffi::c_void,
pub punkAssociationInfo: *mut core::ffi::c_void,
pub cKeys: u32,
pub aKeys: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type DEFCONTEXTMENU struct {
hwnd uintptr
pcmcb uintptr
pidlFolder uintptr
psf uintptr
cidl uint32
apidl uintptr
punkAssociationInfo uintptr
cKeys uint32
aKeys uintptr
}type
DEFCONTEXTMENU = record
hwnd: Pointer;
pcmcb: Pointer;
pidlFolder: Pointer;
psf: Pointer;
cidl: DWORD;
apidl: Pointer;
punkAssociationInfo: Pointer;
cKeys: DWORD;
aKeys: Pointer;
end;const DEFCONTEXTMENU = extern struct {
hwnd: ?*anyopaque,
pcmcb: ?*anyopaque,
pidlFolder: ?*anyopaque,
psf: ?*anyopaque,
cidl: u32,
apidl: ?*anyopaque,
punkAssociationInfo: ?*anyopaque,
cKeys: u32,
aKeys: ?*anyopaque,
};type
DEFCONTEXTMENU {.bycopy.} = object
hwnd: pointer
pcmcb: pointer
pidlFolder: pointer
psf: pointer
cidl: uint32
apidl: pointer
punkAssociationInfo: pointer
cKeys: uint32
aKeys: pointerstruct DEFCONTEXTMENU
{
void* hwnd;
void* pcmcb;
void* pidlFolder;
void* psf;
uint cidl;
void* apidl;
void* punkAssociationInfo;
uint cKeys;
void* aKeys;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DEFCONTEXTMENU サイズ: 36 バイト(x86)
dim st, 9 ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; hwnd : HWND (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pcmcb : IContextMenuCB* (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; pidlFolder : ITEMIDLIST* (+8, 4byte) varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; psf : IShellFolder* (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; cidl : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; apidl : ITEMIDLIST** (+20, 4byte) varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; punkAssociationInfo : IUnknown* (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; cKeys : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; aKeys : HKEY* (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DEFCONTEXTMENU サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; hwnd : HWND (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; pcmcb : IContextMenuCB* (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pidlFolder : ITEMIDLIST* (+16, 8byte) varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; psf : IShellFolder* (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; cidl : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; apidl : ITEMIDLIST** (+40, 8byte) varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; punkAssociationInfo : IUnknown* (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; cKeys : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; aKeys : HKEY* (+64, 8byte) qpoke st,64,値 / qpeek(st,64) ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DEFCONTEXTMENU
#field intptr hwnd
#field intptr pcmcb
#field intptr pidlFolder
#field intptr psf
#field int cidl
#field intptr apidl
#field intptr punkAssociationInfo
#field int cKeys
#field intptr aKeys
#endstruct
stdim st, DEFCONTEXTMENU ; NSTRUCT 変数を確保
st->cidl = 100
mes "cidl=" + st->cidl