Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › WaitForDebugEventEx

WaitForDebugEventEx

関数
デバッグイベントの発生を待機する拡張版関数である。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows 10 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL WaitForDebugEventEx(
    DEBUG_EVENT* lpDebugEvent,
    DWORD dwMilliseconds
);

パラメーター

名前方向
lpDebugEventDEBUG_EVENT*out
dwMillisecondsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL WaitForDebugEventEx(
    DEBUG_EVENT* lpDebugEvent,
    DWORD dwMilliseconds
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool WaitForDebugEventEx(
    IntPtr lpDebugEvent,   // DEBUG_EVENT* out
    uint dwMilliseconds   // DWORD
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WaitForDebugEventEx(
    lpDebugEvent As IntPtr,   ' DEBUG_EVENT* out
    dwMilliseconds As UInteger   ' DWORD
) As Boolean
End Function
' lpDebugEvent : DEBUG_EVENT* out
' dwMilliseconds : DWORD
Declare PtrSafe Function WaitForDebugEventEx Lib "kernel32" ( _
    ByVal lpDebugEvent As LongPtr, _
    ByVal dwMilliseconds As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WaitForDebugEventEx = ctypes.windll.kernel32.WaitForDebugEventEx
WaitForDebugEventEx.restype = wintypes.BOOL
WaitForDebugEventEx.argtypes = [
    ctypes.c_void_p,  # lpDebugEvent : DEBUG_EVENT* out
    wintypes.DWORD,  # dwMilliseconds : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
WaitForDebugEventEx = Fiddle::Function.new(
  lib['WaitForDebugEventEx'],
  [
    Fiddle::TYPE_VOIDP,  # lpDebugEvent : DEBUG_EVENT* out
    -Fiddle::TYPE_INT,  # dwMilliseconds : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn WaitForDebugEventEx(
        lpDebugEvent: *mut DEBUG_EVENT,  // DEBUG_EVENT* out
        dwMilliseconds: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool WaitForDebugEventEx(IntPtr lpDebugEvent, uint dwMilliseconds);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_WaitForDebugEventEx' -Namespace Win32 -PassThru
# $api::WaitForDebugEventEx(lpDebugEvent, dwMilliseconds)
#uselib "KERNEL32.dll"
#func global WaitForDebugEventEx "WaitForDebugEventEx" sptr, sptr
; WaitForDebugEventEx varptr(lpDebugEvent), dwMilliseconds   ; 戻り値は stat
; lpDebugEvent : DEBUG_EVENT* out -> "sptr"
; dwMilliseconds : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global WaitForDebugEventEx "WaitForDebugEventEx" var, int
; res = WaitForDebugEventEx(lpDebugEvent, dwMilliseconds)
; lpDebugEvent : DEBUG_EVENT* out -> "var"
; dwMilliseconds : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL WaitForDebugEventEx(DEBUG_EVENT* lpDebugEvent, DWORD dwMilliseconds)
#uselib "KERNEL32.dll"
#cfunc global WaitForDebugEventEx "WaitForDebugEventEx" var, int
; res = WaitForDebugEventEx(lpDebugEvent, dwMilliseconds)
; lpDebugEvent : DEBUG_EVENT* out -> "var"
; dwMilliseconds : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procWaitForDebugEventEx = kernel32.NewProc("WaitForDebugEventEx")
)

// lpDebugEvent (DEBUG_EVENT* out), dwMilliseconds (DWORD)
r1, _, err := procWaitForDebugEventEx.Call(
	uintptr(lpDebugEvent),
	uintptr(dwMilliseconds),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function WaitForDebugEventEx(
  lpDebugEvent: Pointer;   // DEBUG_EVENT* out
  dwMilliseconds: DWORD   // DWORD
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'WaitForDebugEventEx';
result := DllCall("KERNEL32\WaitForDebugEventEx"
    , "Ptr", lpDebugEvent   ; DEBUG_EVENT* out
    , "UInt", dwMilliseconds   ; DWORD
    , "Int")   ; return: BOOL
●WaitForDebugEventEx(lpDebugEvent, dwMilliseconds) = DLL("KERNEL32.dll", "bool WaitForDebugEventEx(void*, dword)")
# 呼び出し: WaitForDebugEventEx(lpDebugEvent, dwMilliseconds)
# lpDebugEvent : DEBUG_EVENT* out -> "void*"
# dwMilliseconds : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。