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