ホーム › System.Threading › WaitForMultipleObjectsEx
WaitForMultipleObjectsEx
関数警告可能モードで複数オブジェクトのシグナルを待機する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
WAIT_EVENT WaitForMultipleObjectsEx(
DWORD nCount,
const HANDLE* lpHandles,
BOOL bWaitAll,
DWORD dwMilliseconds,
BOOL bAlertable
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| nCount | DWORD | in |
| lpHandles | HANDLE* | in |
| bWaitAll | BOOL | in |
| dwMilliseconds | DWORD | in |
| bAlertable | BOOL | in |
戻り値の型: WAIT_EVENT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
WAIT_EVENT WaitForMultipleObjectsEx(
DWORD nCount,
const HANDLE* lpHandles,
BOOL bWaitAll,
DWORD dwMilliseconds,
BOOL bAlertable
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern uint WaitForMultipleObjectsEx(
uint nCount, // DWORD
IntPtr lpHandles, // HANDLE*
bool bWaitAll, // BOOL
uint dwMilliseconds, // DWORD
bool bAlertable // BOOL
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WaitForMultipleObjectsEx(
nCount As UInteger, ' DWORD
lpHandles As IntPtr, ' HANDLE*
bWaitAll As Boolean, ' BOOL
dwMilliseconds As UInteger, ' DWORD
bAlertable As Boolean ' BOOL
) As UInteger
End Function' nCount : DWORD
' lpHandles : HANDLE*
' bWaitAll : BOOL
' dwMilliseconds : DWORD
' bAlertable : BOOL
Declare PtrSafe Function WaitForMultipleObjectsEx Lib "kernel32" ( _
ByVal nCount As Long, _
ByVal lpHandles As LongPtr, _
ByVal bWaitAll As Long, _
ByVal dwMilliseconds As Long, _
ByVal bAlertable As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WaitForMultipleObjectsEx = ctypes.windll.kernel32.WaitForMultipleObjectsEx
WaitForMultipleObjectsEx.restype = wintypes.DWORD
WaitForMultipleObjectsEx.argtypes = [
wintypes.DWORD, # nCount : DWORD
ctypes.c_void_p, # lpHandles : HANDLE*
wintypes.BOOL, # bWaitAll : BOOL
wintypes.DWORD, # dwMilliseconds : DWORD
wintypes.BOOL, # bAlertable : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
WaitForMultipleObjectsEx = Fiddle::Function.new(
lib['WaitForMultipleObjectsEx'],
[
-Fiddle::TYPE_INT, # nCount : DWORD
Fiddle::TYPE_VOIDP, # lpHandles : HANDLE*
Fiddle::TYPE_INT, # bWaitAll : BOOL
-Fiddle::TYPE_INT, # dwMilliseconds : DWORD
Fiddle::TYPE_INT, # bAlertable : BOOL
],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn WaitForMultipleObjectsEx(
nCount: u32, // DWORD
lpHandles: *mut *mut core::ffi::c_void, // HANDLE*
bWaitAll: i32, // BOOL
dwMilliseconds: u32, // DWORD
bAlertable: i32 // BOOL
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern uint WaitForMultipleObjectsEx(uint nCount, IntPtr lpHandles, bool bWaitAll, uint dwMilliseconds, bool bAlertable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_WaitForMultipleObjectsEx' -Namespace Win32 -PassThru
# $api::WaitForMultipleObjectsEx(nCount, lpHandles, bWaitAll, dwMilliseconds, bAlertable)#uselib "KERNEL32.dll"
#func global WaitForMultipleObjectsEx "WaitForMultipleObjectsEx" sptr, sptr, sptr, sptr, sptr
; WaitForMultipleObjectsEx nCount, lpHandles, bWaitAll, dwMilliseconds, bAlertable ; 戻り値は stat
; nCount : DWORD -> "sptr"
; lpHandles : HANDLE* -> "sptr"
; bWaitAll : BOOL -> "sptr"
; dwMilliseconds : DWORD -> "sptr"
; bAlertable : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global WaitForMultipleObjectsEx "WaitForMultipleObjectsEx" int, sptr, int, int, int
; res = WaitForMultipleObjectsEx(nCount, lpHandles, bWaitAll, dwMilliseconds, bAlertable)
; nCount : DWORD -> "int"
; lpHandles : HANDLE* -> "sptr"
; bWaitAll : BOOL -> "int"
; dwMilliseconds : DWORD -> "int"
; bAlertable : BOOL -> "int"; WAIT_EVENT WaitForMultipleObjectsEx(DWORD nCount, HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds, BOOL bAlertable)
#uselib "KERNEL32.dll"
#cfunc global WaitForMultipleObjectsEx "WaitForMultipleObjectsEx" int, intptr, int, int, int
; res = WaitForMultipleObjectsEx(nCount, lpHandles, bWaitAll, dwMilliseconds, bAlertable)
; nCount : DWORD -> "int"
; lpHandles : HANDLE* -> "intptr"
; bWaitAll : BOOL -> "int"
; dwMilliseconds : DWORD -> "int"
; bAlertable : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procWaitForMultipleObjectsEx = kernel32.NewProc("WaitForMultipleObjectsEx")
)
// nCount (DWORD), lpHandles (HANDLE*), bWaitAll (BOOL), dwMilliseconds (DWORD), bAlertable (BOOL)
r1, _, err := procWaitForMultipleObjectsEx.Call(
uintptr(nCount),
uintptr(lpHandles),
uintptr(bWaitAll),
uintptr(dwMilliseconds),
uintptr(bAlertable),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WAIT_EVENTfunction WaitForMultipleObjectsEx(
nCount: DWORD; // DWORD
lpHandles: Pointer; // HANDLE*
bWaitAll: BOOL; // BOOL
dwMilliseconds: DWORD; // DWORD
bAlertable: BOOL // BOOL
): DWORD; stdcall;
external 'KERNEL32.dll' name 'WaitForMultipleObjectsEx';result := DllCall("KERNEL32\WaitForMultipleObjectsEx"
, "UInt", nCount ; DWORD
, "Ptr", lpHandles ; HANDLE*
, "Int", bWaitAll ; BOOL
, "UInt", dwMilliseconds ; DWORD
, "Int", bAlertable ; BOOL
, "UInt") ; return: WAIT_EVENT●WaitForMultipleObjectsEx(nCount, lpHandles, bWaitAll, dwMilliseconds, bAlertable) = DLL("KERNEL32.dll", "dword WaitForMultipleObjectsEx(dword, void*, bool, dword, bool)")
# 呼び出し: WaitForMultipleObjectsEx(nCount, lpHandles, bWaitAll, dwMilliseconds, bAlertable)
# nCount : DWORD -> "dword"
# lpHandles : HANDLE* -> "void*"
# bWaitAll : BOOL -> "bool"
# dwMilliseconds : DWORD -> "dword"
# bAlertable : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。