ShellExecuteExA
関数指定したファイルやプログラムをシェル経由で実行する。
シグネチャ
// SHELL32.dll (ANSI / -A)
#include <windows.h>
BOOL ShellExecuteExA(
SHELLEXECUTEINFOA* pExecInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pExecInfo | SHELLEXECUTEINFOA* | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// SHELL32.dll (ANSI / -A)
#include <windows.h>
BOOL ShellExecuteExA(
SHELLEXECUTEINFOA* pExecInfo
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool ShellExecuteExA(
IntPtr pExecInfo // SHELLEXECUTEINFOA* in/out
);<DllImport("SHELL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ShellExecuteExA(
pExecInfo As IntPtr ' SHELLEXECUTEINFOA* in/out
) As Boolean
End Function' pExecInfo : SHELLEXECUTEINFOA* in/out
Declare PtrSafe Function ShellExecuteExA Lib "shell32" ( _
ByVal pExecInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ShellExecuteExA = ctypes.windll.shell32.ShellExecuteExA
ShellExecuteExA.restype = wintypes.BOOL
ShellExecuteExA.argtypes = [
ctypes.c_void_p, # pExecInfo : SHELLEXECUTEINFOA* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
ShellExecuteExA = Fiddle::Function.new(
lib['ShellExecuteExA'],
[
Fiddle::TYPE_VOIDP, # pExecInfo : SHELLEXECUTEINFOA* in/out
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn ShellExecuteExA(
pExecInfo: *mut SHELLEXECUTEINFOA // SHELLEXECUTEINFOA* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool ShellExecuteExA(IntPtr pExecInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_ShellExecuteExA' -Namespace Win32 -PassThru
# $api::ShellExecuteExA(pExecInfo)#uselib "SHELL32.dll"
#func global ShellExecuteExA "ShellExecuteExA" sptr
; ShellExecuteExA varptr(pExecInfo) ; 戻り値は stat
; pExecInfo : SHELLEXECUTEINFOA* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global ShellExecuteExA "ShellExecuteExA" var ; res = ShellExecuteExA(pExecInfo) ; pExecInfo : SHELLEXECUTEINFOA* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global ShellExecuteExA "ShellExecuteExA" sptr ; res = ShellExecuteExA(varptr(pExecInfo)) ; pExecInfo : SHELLEXECUTEINFOA* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL ShellExecuteExA(SHELLEXECUTEINFOA* pExecInfo) #uselib "SHELL32.dll" #cfunc global ShellExecuteExA "ShellExecuteExA" var ; res = ShellExecuteExA(pExecInfo) ; pExecInfo : SHELLEXECUTEINFOA* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL ShellExecuteExA(SHELLEXECUTEINFOA* pExecInfo) #uselib "SHELL32.dll" #cfunc global ShellExecuteExA "ShellExecuteExA" intptr ; res = ShellExecuteExA(varptr(pExecInfo)) ; pExecInfo : SHELLEXECUTEINFOA* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procShellExecuteExA = shell32.NewProc("ShellExecuteExA")
)
// pExecInfo (SHELLEXECUTEINFOA* in/out)
r1, _, err := procShellExecuteExA.Call(
uintptr(pExecInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction ShellExecuteExA(
pExecInfo: Pointer // SHELLEXECUTEINFOA* in/out
): BOOL; stdcall;
external 'SHELL32.dll' name 'ShellExecuteExA';result := DllCall("SHELL32\ShellExecuteExA"
, "Ptr", pExecInfo ; SHELLEXECUTEINFOA* in/out
, "Int") ; return: BOOL●ShellExecuteExA(pExecInfo) = DLL("SHELL32.dll", "bool ShellExecuteExA(void*)")
# 呼び出し: ShellExecuteExA(pExecInfo)
# pExecInfo : SHELLEXECUTEINFOA* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。