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

DialogBoxIndirectParamA

関数
メモリ上テンプレートからモーダルダイアログを実行する(ANSI)。
DLLUSER32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

INT_PTR DialogBoxIndirectParamA(
    HINSTANCE hInstance,   // optional
    DLGTEMPLATE* hDialogTemplate,
    HWND hWndParent,   // optional
    DLGPROC lpDialogFunc,   // optional
    LPARAM dwInitParam
);

パラメーター

名前方向
hInstanceHINSTANCEinoptional
hDialogTemplateDLGTEMPLATE*in
hWndParentHWNDinoptional
lpDialogFuncDLGPROCinoptional
dwInitParamLPARAMin

戻り値の型: INT_PTR

各言語での呼び出し定義

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

INT_PTR DialogBoxIndirectParamA(
    HINSTANCE hInstance,   // optional
    DLGTEMPLATE* hDialogTemplate,
    HWND hWndParent,   // optional
    DLGPROC lpDialogFunc,   // optional
    LPARAM dwInitParam
);
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr DialogBoxIndirectParamA(
    IntPtr hInstance,   // HINSTANCE optional
    IntPtr hDialogTemplate,   // DLGTEMPLATE*
    IntPtr hWndParent,   // HWND optional
    IntPtr lpDialogFunc,   // DLGPROC optional
    IntPtr dwInitParam   // LPARAM
);
<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DialogBoxIndirectParamA(
    hInstance As IntPtr,   ' HINSTANCE optional
    hDialogTemplate As IntPtr,   ' DLGTEMPLATE*
    hWndParent As IntPtr,   ' HWND optional
    lpDialogFunc As IntPtr,   ' DLGPROC optional
    dwInitParam As IntPtr   ' LPARAM
) As IntPtr
End Function
' hInstance : HINSTANCE optional
' hDialogTemplate : DLGTEMPLATE*
' hWndParent : HWND optional
' lpDialogFunc : DLGPROC optional
' dwInitParam : LPARAM
Declare PtrSafe Function DialogBoxIndirectParamA Lib "user32" ( _
    ByVal hInstance As LongPtr, _
    ByVal hDialogTemplate As LongPtr, _
    ByVal hWndParent As LongPtr, _
    ByVal lpDialogFunc As LongPtr, _
    ByVal dwInitParam As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DialogBoxIndirectParamA = ctypes.windll.user32.DialogBoxIndirectParamA
DialogBoxIndirectParamA.restype = ctypes.c_ssize_t
DialogBoxIndirectParamA.argtypes = [
    wintypes.HANDLE,  # hInstance : HINSTANCE optional
    ctypes.c_void_p,  # hDialogTemplate : DLGTEMPLATE*
    wintypes.HANDLE,  # hWndParent : HWND optional
    ctypes.c_void_p,  # lpDialogFunc : DLGPROC optional
    ctypes.c_ssize_t,  # dwInitParam : LPARAM
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
DialogBoxIndirectParamA = Fiddle::Function.new(
  lib['DialogBoxIndirectParamA'],
  [
    Fiddle::TYPE_VOIDP,  # hInstance : HINSTANCE optional
    Fiddle::TYPE_VOIDP,  # hDialogTemplate : DLGTEMPLATE*
    Fiddle::TYPE_VOIDP,  # hWndParent : HWND optional
    Fiddle::TYPE_VOIDP,  # lpDialogFunc : DLGPROC optional
    Fiddle::TYPE_INTPTR_T,  # dwInitParam : LPARAM
  ],
  Fiddle::TYPE_INTPTR_T)
#[link(name = "user32")]
extern "system" {
    fn DialogBoxIndirectParamA(
        hInstance: *mut core::ffi::c_void,  // HINSTANCE optional
        hDialogTemplate: *mut DLGTEMPLATE,  // DLGTEMPLATE*
        hWndParent: *mut core::ffi::c_void,  // HWND optional
        lpDialogFunc: *const core::ffi::c_void,  // DLGPROC optional
        dwInitParam: isize  // LPARAM
    ) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr DialogBoxIndirectParamA(IntPtr hInstance, IntPtr hDialogTemplate, IntPtr hWndParent, IntPtr lpDialogFunc, IntPtr dwInitParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DialogBoxIndirectParamA' -Namespace Win32 -PassThru
# $api::DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam)
#uselib "USER32.dll"
#func global DialogBoxIndirectParamA "DialogBoxIndirectParamA" sptr, sptr, sptr, sptr, sptr
; DialogBoxIndirectParamA hInstance, varptr(hDialogTemplate), hWndParent, lpDialogFunc, dwInitParam   ; 戻り値は stat
; hInstance : HINSTANCE optional -> "sptr"
; hDialogTemplate : DLGTEMPLATE* -> "sptr"
; hWndParent : HWND optional -> "sptr"
; lpDialogFunc : DLGPROC optional -> "sptr"
; dwInitParam : LPARAM -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global DialogBoxIndirectParamA "DialogBoxIndirectParamA" sptr, var, sptr, sptr, sptr
; res = DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam)
; hInstance : HINSTANCE optional -> "sptr"
; hDialogTemplate : DLGTEMPLATE* -> "var"
; hWndParent : HWND optional -> "sptr"
; lpDialogFunc : DLGPROC optional -> "sptr"
; dwInitParam : LPARAM -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT_PTR DialogBoxIndirectParamA(HINSTANCE hInstance, DLGTEMPLATE* hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam)
#uselib "USER32.dll"
#cfunc global DialogBoxIndirectParamA "DialogBoxIndirectParamA" intptr, var, intptr, intptr, intptr
; res = DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam)
; hInstance : HINSTANCE optional -> "intptr"
; hDialogTemplate : DLGTEMPLATE* -> "var"
; hWndParent : HWND optional -> "intptr"
; lpDialogFunc : DLGPROC optional -> "intptr"
; dwInitParam : LPARAM -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDialogBoxIndirectParamA = user32.NewProc("DialogBoxIndirectParamA")
)

// hInstance (HINSTANCE optional), hDialogTemplate (DLGTEMPLATE*), hWndParent (HWND optional), lpDialogFunc (DLGPROC optional), dwInitParam (LPARAM)
r1, _, err := procDialogBoxIndirectParamA.Call(
	uintptr(hInstance),
	uintptr(hDialogTemplate),
	uintptr(hWndParent),
	uintptr(lpDialogFunc),
	uintptr(dwInitParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT_PTR
function DialogBoxIndirectParamA(
  hInstance: THandle;   // HINSTANCE optional
  hDialogTemplate: Pointer;   // DLGTEMPLATE*
  hWndParent: THandle;   // HWND optional
  lpDialogFunc: Pointer;   // DLGPROC optional
  dwInitParam: NativeInt   // LPARAM
): NativeInt; stdcall;
  external 'USER32.dll' name 'DialogBoxIndirectParamA';
result := DllCall("USER32\DialogBoxIndirectParamA"
    , "Ptr", hInstance   ; HINSTANCE optional
    , "Ptr", hDialogTemplate   ; DLGTEMPLATE*
    , "Ptr", hWndParent   ; HWND optional
    , "Ptr", lpDialogFunc   ; DLGPROC optional
    , "Ptr", dwInitParam   ; LPARAM
    , "Ptr")   ; return: INT_PTR
●DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam) = DLL("USER32.dll", "int DialogBoxIndirectParamA(void*, void*, void*, void*, int)")
# 呼び出し: DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam)
# hInstance : HINSTANCE optional -> "void*"
# hDialogTemplate : DLGTEMPLATE* -> "void*"
# hWndParent : HWND optional -> "void*"
# lpDialogFunc : DLGPROC optional -> "void*"
# dwInitParam : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。