SHELLEXECUTEINFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | この構造体のサイズをバイト単位で指定する。 |
| fMask | DWORD | 4 | +4 | +4 | 有効なメンバーや動作を示すフラグ(SEE_MASK_ 系)。 |
| hwnd | HWND | 8/4 | +8 | +8 | エラーや UI 表示の親ウィンドウのハンドル。 |
| lpVerb | LPWSTR | 8/4 | +16 | +12 | 実行する動作(open、edit、runas 等)を指定する文字列。NULL 可。 |
| lpFile | LPWSTR | 8/4 | +24 | +16 | 実行・操作対象のファイルやオブジェクト名(Unicode)。 |
| lpParameters | LPWSTR | 8/4 | +32 | +20 | 実行ファイルに渡すパラメータ文字列。NULL 可。 |
| lpDirectory | LPWSTR | 8/4 | +40 | +24 | 作業ディレクトリを指定する文字列。NULL 可。 |
| nShow | INT | 4 | +48 | +28 | 起動したアプリのウィンドウ表示状態(SW_ 系)。 |
| hInstApp | HINSTANCE | 8/4 | +52 | +32 | 出力: 32未満ならエラーコードを示す疑似的なインスタンスハンドル。 |
| lpIDList | void* | 8/4 | +60 | +36 | オブジェクトを指す PIDL。SEE_MASK_IDLIST 指定時に有効。 |
| lpClass | LPWSTR | 8/4 | +68 | +40 | ファイルのクラス名。SEE_MASK_CLASSNAME 指定時に有効。 |
| hkeyClass | HKEY | 8/4 | +76 | +44 | クラス情報のレジストリキー。SEE_MASK_CLASSKEY 指定時に有効。 |
| dwHotKey | DWORD | 4 | +84 | +48 | 登録するホットキー。SEE_MASK_HOTKEY 指定時に有効。 |
| Anonymous | _Anonymous_e__Union | 8/4 | +88 | +52 | hIcon と hMonitor を共用する無名共用体。フラグに応じて使い分ける。 |
| hProcess | HANDLE | 8/4 | +96 | +56 | 出力: 起動プロセスのハンドル。SEE_MASK_NOCLOSEPROCESS 指定時に有効。 |
共用体: _Anonymous_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| hIcon | HANDLE | 8/4 | +0 | +0 |
| hMonitor | HANDLE | 8/4 | +0 | +0 |
各言語での定義
#include <windows.h>
// SHELLEXECUTEINFOW (x64 104 / x86 60 バイト)
#pragma pack(push, 1)
typedef struct SHELLEXECUTEINFOW {
DWORD cbSize;
DWORD fMask;
HWND hwnd;
LPWSTR lpVerb;
LPWSTR lpFile;
LPWSTR lpParameters;
LPWSTR lpDirectory;
INT nShow;
HINSTANCE hInstApp;
void* lpIDList;
LPWSTR lpClass;
HKEY hkeyClass;
DWORD dwHotKey;
_Anonymous_e__Union Anonymous;
HANDLE hProcess;
} SHELLEXECUTEINFOW;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SHELLEXECUTEINFOW
{
public uint cbSize;
public uint fMask;
public IntPtr hwnd;
public IntPtr lpVerb;
public IntPtr lpFile;
public IntPtr lpParameters;
public IntPtr lpDirectory;
public int nShow;
public IntPtr hInstApp;
public IntPtr lpIDList;
public IntPtr lpClass;
public IntPtr hkeyClass;
public uint dwHotKey;
public _Anonymous_e__Union Anonymous;
public IntPtr hProcess;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SHELLEXECUTEINFOW
Public cbSize As UInteger
Public fMask As UInteger
Public hwnd As IntPtr
Public lpVerb As IntPtr
Public lpFile As IntPtr
Public lpParameters As IntPtr
Public lpDirectory As IntPtr
Public nShow As Integer
Public hInstApp As IntPtr
Public lpIDList As IntPtr
Public lpClass As IntPtr
Public hkeyClass As IntPtr
Public dwHotKey As UInteger
Public Anonymous As _Anonymous_e__Union
Public hProcess As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class SHELLEXECUTEINFOW(ctypes.Structure):
_pack_ = 1
_fields_ = [
("cbSize", wintypes.DWORD),
("fMask", wintypes.DWORD),
("hwnd", ctypes.c_void_p),
("lpVerb", ctypes.c_void_p),
("lpFile", ctypes.c_void_p),
("lpParameters", ctypes.c_void_p),
("lpDirectory", ctypes.c_void_p),
("nShow", ctypes.c_int),
("hInstApp", ctypes.c_void_p),
("lpIDList", ctypes.c_void_p),
("lpClass", ctypes.c_void_p),
("hkeyClass", ctypes.c_void_p),
("dwHotKey", wintypes.DWORD),
("Anonymous", _Anonymous_e__Union),
("hProcess", ctypes.c_void_p),
]#[repr(C, packed(1))]
pub struct SHELLEXECUTEINFOW {
pub cbSize: u32,
pub fMask: u32,
pub hwnd: *mut core::ffi::c_void,
pub lpVerb: *mut core::ffi::c_void,
pub lpFile: *mut core::ffi::c_void,
pub lpParameters: *mut core::ffi::c_void,
pub lpDirectory: *mut core::ffi::c_void,
pub nShow: i32,
pub hInstApp: *mut core::ffi::c_void,
pub lpIDList: *mut core::ffi::c_void,
pub lpClass: *mut core::ffi::c_void,
pub hkeyClass: *mut core::ffi::c_void,
pub dwHotKey: u32,
pub Anonymous: _Anonymous_e__Union,
pub hProcess: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type SHELLEXECUTEINFOW struct {
cbSize uint32
fMask uint32
hwnd uintptr
lpVerb uintptr
lpFile uintptr
lpParameters uintptr
lpDirectory uintptr
nShow int32
hInstApp uintptr
lpIDList uintptr
lpClass uintptr
hkeyClass uintptr
dwHotKey uint32
Anonymous _Anonymous_e__Union
hProcess uintptr
}type
SHELLEXECUTEINFOW = packed record
cbSize: DWORD;
fMask: DWORD;
hwnd: Pointer;
lpVerb: Pointer;
lpFile: Pointer;
lpParameters: Pointer;
lpDirectory: Pointer;
nShow: Integer;
hInstApp: Pointer;
lpIDList: Pointer;
lpClass: Pointer;
hkeyClass: Pointer;
dwHotKey: DWORD;
Anonymous: _Anonymous_e__Union;
hProcess: Pointer;
end;const SHELLEXECUTEINFOW = extern struct {
cbSize: u32,
fMask: u32,
hwnd: ?*anyopaque,
lpVerb: ?*anyopaque,
lpFile: ?*anyopaque,
lpParameters: ?*anyopaque,
lpDirectory: ?*anyopaque,
nShow: i32,
hInstApp: ?*anyopaque,
lpIDList: ?*anyopaque,
lpClass: ?*anyopaque,
hkeyClass: ?*anyopaque,
dwHotKey: u32,
Anonymous: _Anonymous_e__Union,
hProcess: ?*anyopaque,
};type
SHELLEXECUTEINFOW {.packed.} = object
cbSize: uint32
fMask: uint32
hwnd: pointer
lpVerb: pointer
lpFile: pointer
lpParameters: pointer
lpDirectory: pointer
nShow: int32
hInstApp: pointer
lpIDList: pointer
lpClass: pointer
hkeyClass: pointer
dwHotKey: uint32
Anonymous: _Anonymous_e__Union
hProcess: pointeralign(1)
struct SHELLEXECUTEINFOW
{
uint cbSize;
uint fMask;
void* hwnd;
void* lpVerb;
void* lpFile;
void* lpParameters;
void* lpDirectory;
int nShow;
void* hInstApp;
void* lpIDList;
void* lpClass;
void* hkeyClass;
uint dwHotKey;
_Anonymous_e__Union Anonymous;
void* hProcess;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SHELLEXECUTEINFOW サイズ: 60 バイト(x86)
dim st, 15 ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; fMask : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; hwnd : HWND (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lpVerb : LPWSTR (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lpFile : LPWSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; lpParameters : LPWSTR (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; lpDirectory : LPWSTR (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; nShow : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; hInstApp : HINSTANCE (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; lpIDList : void* (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; lpClass : LPWSTR (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; hkeyClass : HKEY (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; dwHotKey : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+52, 4byte) varptr(st)+52 を基点に操作(4byte:入れ子/配列)
; hProcess : HANDLE (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SHELLEXECUTEINFOW サイズ: 104 バイト(x64)
dim st, 26 ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; fMask : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; hwnd : HWND (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; lpVerb : LPWSTR (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; lpFile : LPWSTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; lpParameters : LPWSTR (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; lpDirectory : LPWSTR (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; nShow : INT (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; hInstApp : HINSTANCE (+52, 8byte) qpoke st,52,値 / qpeek(st,52) ※IronHSPのみ。3.7/3.8は lpoke st,52,下位 : lpoke st,56,上位
; lpIDList : void* (+60, 8byte) qpoke st,60,値 / qpeek(st,60) ※IronHSPのみ。3.7/3.8は lpoke st,60,下位 : lpoke st,64,上位
; lpClass : LPWSTR (+68, 8byte) qpoke st,68,値 / qpeek(st,68) ※IronHSPのみ。3.7/3.8は lpoke st,68,下位 : lpoke st,72,上位
; hkeyClass : HKEY (+76, 8byte) qpoke st,76,値 / qpeek(st,76) ※IronHSPのみ。3.7/3.8は lpoke st,76,下位 : lpoke st,80,上位
; dwHotKey : DWORD (+84, 4byte) st.21 = 値 / 値 = st.21 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+88, 8byte) varptr(st)+88 を基点に操作(8byte:入れ子/配列)
; hProcess : HANDLE (+96, 8byte) qpoke st,96,値 / qpeek(st,96) ※IronHSPのみ。3.7/3.8は lpoke st,96,下位 : lpoke st,100,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SHELLEXECUTEINFOW, pack=1
#field int cbSize
#field int fMask
#field intptr hwnd
#field intptr lpVerb
#field intptr lpFile
#field intptr lpParameters
#field intptr lpDirectory
#field int nShow
#field intptr hInstApp
#field intptr lpIDList
#field intptr lpClass
#field intptr hkeyClass
#field int dwHotKey
#field byte Anonymous 8
#field intptr hProcess
#endstruct
stdim st, SHELLEXECUTEINFOW ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。