ホーム › System.ClrHosting › RunDll32ShimW
RunDll32ShimW
関数rundll32経由でマネージドエントリポイントを起動するシムを実行する。
シグネチャ
// MSCorEE.dll
#include <windows.h>
HRESULT RunDll32ShimW(
HWND hwnd,
HINSTANCE hinst,
LPCWSTR lpszCmdLine,
INT nCmdShow
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | 呼び出し元ウィンドウのハンドル。rundll32 互換のため指定する。 |
| hinst | HINSTANCE | in | 呼び出し元インスタンスのハンドル。rundll32 互換のため指定する。 |
| lpszCmdLine | LPCWSTR | in | 実行するコマンドラインを示す文字列。Unicode 文字列で指定する。 |
| nCmdShow | INT | in | ウィンドウ表示状態を示す値。SW_SHOW 等を指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// MSCorEE.dll
#include <windows.h>
HRESULT RunDll32ShimW(
HWND hwnd,
HINSTANCE hinst,
LPCWSTR lpszCmdLine,
INT nCmdShow
);[DllImport("MSCorEE.dll", ExactSpelling = true)]
static extern int RunDll32ShimW(
IntPtr hwnd, // HWND
IntPtr hinst, // HINSTANCE
[MarshalAs(UnmanagedType.LPWStr)] string lpszCmdLine, // LPCWSTR
int nCmdShow // INT
);<DllImport("MSCorEE.dll", ExactSpelling:=True)>
Public Shared Function RunDll32ShimW(
hwnd As IntPtr, ' HWND
hinst As IntPtr, ' HINSTANCE
<MarshalAs(UnmanagedType.LPWStr)> lpszCmdLine As String, ' LPCWSTR
nCmdShow As Integer ' INT
) As Integer
End Function' hwnd : HWND
' hinst : HINSTANCE
' lpszCmdLine : LPCWSTR
' nCmdShow : INT
Declare PtrSafe Function RunDll32ShimW Lib "mscoree" ( _
ByVal hwnd As LongPtr, _
ByVal hinst As LongPtr, _
ByVal lpszCmdLine As LongPtr, _
ByVal nCmdShow As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RunDll32ShimW = ctypes.windll.mscoree.RunDll32ShimW
RunDll32ShimW.restype = ctypes.c_int
RunDll32ShimW.argtypes = [
wintypes.HANDLE, # hwnd : HWND
wintypes.HANDLE, # hinst : HINSTANCE
wintypes.LPCWSTR, # lpszCmdLine : LPCWSTR
ctypes.c_int, # nCmdShow : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSCorEE.dll')
RunDll32ShimW = Fiddle::Function.new(
lib['RunDll32ShimW'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # hinst : HINSTANCE
Fiddle::TYPE_VOIDP, # lpszCmdLine : LPCWSTR
Fiddle::TYPE_INT, # nCmdShow : INT
],
Fiddle::TYPE_INT)#[link(name = "mscoree")]
extern "system" {
fn RunDll32ShimW(
hwnd: *mut core::ffi::c_void, // HWND
hinst: *mut core::ffi::c_void, // HINSTANCE
lpszCmdLine: *const u16, // LPCWSTR
nCmdShow: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSCorEE.dll")]
public static extern int RunDll32ShimW(IntPtr hwnd, IntPtr hinst, [MarshalAs(UnmanagedType.LPWStr)] string lpszCmdLine, int nCmdShow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSCorEE_RunDll32ShimW' -Namespace Win32 -PassThru
# $api::RunDll32ShimW(hwnd, hinst, lpszCmdLine, nCmdShow)#uselib "MSCorEE.dll"
#func global RunDll32ShimW "RunDll32ShimW" sptr, sptr, sptr, sptr
; RunDll32ShimW hwnd, hinst, lpszCmdLine, nCmdShow ; 戻り値は stat
; hwnd : HWND -> "sptr"
; hinst : HINSTANCE -> "sptr"
; lpszCmdLine : LPCWSTR -> "sptr"
; nCmdShow : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MSCorEE.dll"
#cfunc global RunDll32ShimW "RunDll32ShimW" sptr, sptr, wstr, int
; res = RunDll32ShimW(hwnd, hinst, lpszCmdLine, nCmdShow)
; hwnd : HWND -> "sptr"
; hinst : HINSTANCE -> "sptr"
; lpszCmdLine : LPCWSTR -> "wstr"
; nCmdShow : INT -> "int"; HRESULT RunDll32ShimW(HWND hwnd, HINSTANCE hinst, LPCWSTR lpszCmdLine, INT nCmdShow)
#uselib "MSCorEE.dll"
#cfunc global RunDll32ShimW "RunDll32ShimW" intptr, intptr, wstr, int
; res = RunDll32ShimW(hwnd, hinst, lpszCmdLine, nCmdShow)
; hwnd : HWND -> "intptr"
; hinst : HINSTANCE -> "intptr"
; lpszCmdLine : LPCWSTR -> "wstr"
; nCmdShow : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscoree = windows.NewLazySystemDLL("MSCorEE.dll")
procRunDll32ShimW = mscoree.NewProc("RunDll32ShimW")
)
// hwnd (HWND), hinst (HINSTANCE), lpszCmdLine (LPCWSTR), nCmdShow (INT)
r1, _, err := procRunDll32ShimW.Call(
uintptr(hwnd),
uintptr(hinst),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszCmdLine))),
uintptr(nCmdShow),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RunDll32ShimW(
hwnd: THandle; // HWND
hinst: THandle; // HINSTANCE
lpszCmdLine: PWideChar; // LPCWSTR
nCmdShow: Integer // INT
): Integer; stdcall;
external 'MSCorEE.dll' name 'RunDll32ShimW';result := DllCall("MSCorEE\RunDll32ShimW"
, "Ptr", hwnd ; HWND
, "Ptr", hinst ; HINSTANCE
, "WStr", lpszCmdLine ; LPCWSTR
, "Int", nCmdShow ; INT
, "Int") ; return: HRESULT●RunDll32ShimW(hwnd, hinst, lpszCmdLine, nCmdShow) = DLL("MSCorEE.dll", "int RunDll32ShimW(void*, void*, char*, int)")
# 呼び出し: RunDll32ShimW(hwnd, hinst, lpszCmdLine, nCmdShow)
# hwnd : HWND -> "void*"
# hinst : HINSTANCE -> "void*"
# lpszCmdLine : LPCWSTR -> "char*"
# nCmdShow : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。