ホーム › UI.WindowsAndMessaging › MessageBoxIndirectW
MessageBoxIndirectW
関数構造体指定でカスタムメッセージボックスを表示する(Unicode版)。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
MESSAGEBOX_RESULT MessageBoxIndirectW(
const MSGBOXPARAMSW* lpmbp
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpmbp | MSGBOXPARAMSW* | in |
戻り値の型: MESSAGEBOX_RESULT
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
MESSAGEBOX_RESULT MessageBoxIndirectW(
const MSGBOXPARAMSW* lpmbp
);[DllImport("USER32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int MessageBoxIndirectW(
IntPtr lpmbp // MSGBOXPARAMSW*
);<DllImport("USER32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MessageBoxIndirectW(
lpmbp As IntPtr ' MSGBOXPARAMSW*
) As Integer
End Function' lpmbp : MSGBOXPARAMSW*
Declare PtrSafe Function MessageBoxIndirectW Lib "user32" ( _
ByVal lpmbp As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MessageBoxIndirectW = ctypes.windll.user32.MessageBoxIndirectW
MessageBoxIndirectW.restype = ctypes.c_int
MessageBoxIndirectW.argtypes = [
ctypes.c_void_p, # lpmbp : MSGBOXPARAMSW*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
MessageBoxIndirectW = Fiddle::Function.new(
lib['MessageBoxIndirectW'],
[
Fiddle::TYPE_VOIDP, # lpmbp : MSGBOXPARAMSW*
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn MessageBoxIndirectW(
lpmbp: *const MSGBOXPARAMSW // MSGBOXPARAMSW*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBoxIndirectW(IntPtr lpmbp);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_MessageBoxIndirectW' -Namespace Win32 -PassThru
# $api::MessageBoxIndirectW(lpmbp)#uselib "USER32.dll"
#func global MessageBoxIndirectW "MessageBoxIndirectW" wptr
; MessageBoxIndirectW varptr(lpmbp) ; 戻り値は stat
; lpmbp : MSGBOXPARAMSW* -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global MessageBoxIndirectW "MessageBoxIndirectW" var ; res = MessageBoxIndirectW(lpmbp) ; lpmbp : MSGBOXPARAMSW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global MessageBoxIndirectW "MessageBoxIndirectW" sptr ; res = MessageBoxIndirectW(varptr(lpmbp)) ; lpmbp : MSGBOXPARAMSW* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; MESSAGEBOX_RESULT MessageBoxIndirectW(MSGBOXPARAMSW* lpmbp) #uselib "USER32.dll" #cfunc global MessageBoxIndirectW "MessageBoxIndirectW" var ; res = MessageBoxIndirectW(lpmbp) ; lpmbp : MSGBOXPARAMSW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; MESSAGEBOX_RESULT MessageBoxIndirectW(MSGBOXPARAMSW* lpmbp) #uselib "USER32.dll" #cfunc global MessageBoxIndirectW "MessageBoxIndirectW" intptr ; res = MessageBoxIndirectW(varptr(lpmbp)) ; lpmbp : MSGBOXPARAMSW* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procMessageBoxIndirectW = user32.NewProc("MessageBoxIndirectW")
)
// lpmbp (MSGBOXPARAMSW*)
r1, _, err := procMessageBoxIndirectW.Call(
uintptr(lpmbp),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // MESSAGEBOX_RESULTfunction MessageBoxIndirectW(
lpmbp: Pointer // MSGBOXPARAMSW*
): Integer; stdcall;
external 'USER32.dll' name 'MessageBoxIndirectW';result := DllCall("USER32\MessageBoxIndirectW"
, "Ptr", lpmbp ; MSGBOXPARAMSW*
, "Int") ; return: MESSAGEBOX_RESULT●MessageBoxIndirectW(lpmbp) = DLL("USER32.dll", "int MessageBoxIndirectW(void*)")
# 呼び出し: MessageBoxIndirectW(lpmbp)
# lpmbp : MSGBOXPARAMSW* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。