Win32 API 日本語リファレンス
ホームUI.WindowsAndMessaging › MessageBoxIndirectA

MessageBoxIndirectA

関数
構造体指定でカスタムメッセージボックスを表示する(ANSI版)。
DLLUSER32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (ANSI / -A)
#include <windows.h>

MESSAGEBOX_RESULT MessageBoxIndirectA(
    const MSGBOXPARAMSA* lpmbp
);

パラメーター

名前方向
lpmbpMSGBOXPARAMSA*in

戻り値の型: MESSAGEBOX_RESULT

各言語での呼び出し定義

// USER32.dll  (ANSI / -A)
#include <windows.h>

MESSAGEBOX_RESULT MessageBoxIndirectA(
    const MSGBOXPARAMSA* lpmbp
);
[DllImport("USER32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int MessageBoxIndirectA(
    IntPtr lpmbp   // MSGBOXPARAMSA*
);
<DllImport("USER32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MessageBoxIndirectA(
    lpmbp As IntPtr   ' MSGBOXPARAMSA*
) As Integer
End Function
' lpmbp : MSGBOXPARAMSA*
Declare PtrSafe Function MessageBoxIndirectA Lib "user32" ( _
    ByVal lpmbp As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MessageBoxIndirectA = ctypes.windll.user32.MessageBoxIndirectA
MessageBoxIndirectA.restype = ctypes.c_int
MessageBoxIndirectA.argtypes = [
    ctypes.c_void_p,  # lpmbp : MSGBOXPARAMSA*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
MessageBoxIndirectA = Fiddle::Function.new(
  lib['MessageBoxIndirectA'],
  [
    Fiddle::TYPE_VOIDP,  # lpmbp : MSGBOXPARAMSA*
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn MessageBoxIndirectA(
        lpmbp: *const MSGBOXPARAMSA  // MSGBOXPARAMSA*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Ansi)]
public static extern int MessageBoxIndirectA(IntPtr lpmbp);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_MessageBoxIndirectA' -Namespace Win32 -PassThru
# $api::MessageBoxIndirectA(lpmbp)
#uselib "USER32.dll"
#func global MessageBoxIndirectA "MessageBoxIndirectA" sptr
; MessageBoxIndirectA varptr(lpmbp)   ; 戻り値は stat
; lpmbp : MSGBOXPARAMSA* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global MessageBoxIndirectA "MessageBoxIndirectA" var
; res = MessageBoxIndirectA(lpmbp)
; lpmbp : MSGBOXPARAMSA* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; MESSAGEBOX_RESULT MessageBoxIndirectA(MSGBOXPARAMSA* lpmbp)
#uselib "USER32.dll"
#cfunc global MessageBoxIndirectA "MessageBoxIndirectA" var
; res = MessageBoxIndirectA(lpmbp)
; lpmbp : MSGBOXPARAMSA* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procMessageBoxIndirectA = user32.NewProc("MessageBoxIndirectA")
)

// lpmbp (MSGBOXPARAMSA*)
r1, _, err := procMessageBoxIndirectA.Call(
	uintptr(lpmbp),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // MESSAGEBOX_RESULT
function MessageBoxIndirectA(
  lpmbp: Pointer   // MSGBOXPARAMSA*
): Integer; stdcall;
  external 'USER32.dll' name 'MessageBoxIndirectA';
result := DllCall("USER32\MessageBoxIndirectA"
    , "Ptr", lpmbp   ; MSGBOXPARAMSA*
    , "Int")   ; return: MESSAGEBOX_RESULT
●MessageBoxIndirectA(lpmbp) = DLL("USER32.dll", "int MessageBoxIndirectA(void*)")
# 呼び出し: MessageBoxIndirectA(lpmbp)
# lpmbp : MSGBOXPARAMSA* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。