网站首页  词典首页

请输入您要查询的函数:

 

术语 msgwaitformultipleobjects
释义 MsgWaitForMultipleObjects
语法:
C++
DWORD WINAPI MsgWaitForMultipleObjects(
__in DWORD nCount,
__in const HANDLE *pHandles,
__in BOOL bWaitAll,
__in DWORD dwMilliseconds,
__in DWORD dwWakeMask
);
MsgWaitForMultipleObjects函数
等待,直到一个或多个指定的所有对象是在信号状态或经过的超时间隔。该对象可以包括输入事件对象,您指定使用dwWakeMask参数。
要输入一个报警等待状态,请使用MsgWaitForMultipleObjectsEx功能。
参数
nCount [in]
对象句柄数指向pHandles数组中。对象句柄的最大数量减去1 MAXIMUM_WAIT_OBJECTS。
pHandles [in]
一个对象的句柄数组。对于一个对象的句柄类型可以指定清单,请参阅下面的备注部分。该阵列可以包含处理不同类型的对象。它不能包含相同的处理多个副本。
如果这些处理一个是封闭,而该等待仍悬而未决,该函数的行为是不确定的。
在处理必须有正确的同步访问。有关更多信息,请参阅标准访问权限。
bWaitAll [in]
如果此参数为TRUE,则函数返回时,在pHandles数组中的所有物体的国家都被设置为输入信号,并已收到的事件。如果此参数为FALSE,函数时,任何一个对象的状态被设置为信号或输入事件返回已经收到。在这种情况下,返回值表示的对象的情况引起的函数返回。
dwMilliseconds的 [in]
在超时间隔时间,以毫秒为单位。如果一个非零值指定的函数等待,直到指定的对象是信号或经过的时间间隔。如果dwMilliseconds的是零,该函数不进入等待状态,如果指定的对象没有信号,它总是立即返回。如果dwMilliseconds的是无限的,该函数将返回只有在指定的对象发出信号。
dwWakeMask [in]
输入类型的输入事件对象句柄将被添加到对象句柄数组。此参数可以是任何下列值的组合。
ValueMeaning
QS_ALLEVENTS
0x04BFAn输入,中WM_TIMER,WM_PAINT消息,WM_HOTKEY,或张贴消息在队列中。
此值是一个QS_INPUT,QS_POSTMESSAGE,QS_TIMER,QS_PAINT和QS_HOTKEY组合。
QS_ALLINPUT
0x04FFAny消息在队列中。
此值是一个QS_INPUT,QS_POSTMESSAGE,QS_TIMER,QS_PAINT,QS_HOTKEY和QS_SENDMESSAGE组合。
QS_ALLPOSTMESSAGE
0x0100A发布消息队列中。
清除此值时调用GetMessage或PeekMessage未经过滤的信息。
QS_HOTKEY
0x0080A WM_HOTKEY消息在队列中。
QS_INPUT
0x407An输入消息队列中。
此值是一个QS_MOUSE,QS_KEY和QS_RAWINPUT组合。
Windows 2000中:此值不包括QS_RAWINPUT。
QS_KEY
0x0001A WM_KEYUP,WM_KEYDOWN,WM_SYSKEYUP,或WM_SYSKEYDOWN消息在队列中。
QS_MOUSE
0x0006A WM_MOUSEMOVE消息或鼠标按钮消息(WM_LBUTTONUP,WM_RBUTTONDOWN等)。
此值是一个QS_MOUSEMOVE和QS_MOUSEBUTTON组合。
QS_MOUSEBUTTON
0x0004A鼠标按键消息(WM_LBUTTONUP,WM_RBUTTONDOWN等)。
QS_MOUSEMOVE
0x0002A WM_MOUSEMOVE消息在队列中。
QS_PAINT
0x0020A WM_PAINT消息在队列中。
QS_POSTMESSAGE
0x0008A发布消息队列中。
清除此值时调用GetMessage或PeekMessage,不管您是筛选信息。
QS_RAWINPUT
0x0400A原始输入消息队列中。有关更多信息,请参阅原始输入。
Windows 2000中:此值不支持。
QS_SENDMESSAGE
0x0040A消息由另一个线程或应用程序发送的队列中。
QS_TIMER
0x0010A WM_TIMER消息在队列中。
返回值
如果函数成功,返回值表示该事件导致该函数返回。它可以是下列值之一。 (请注意,WAIT_OBJECT_0被定义为0和WAIT_ABANDONED_0是0x00000080L定义。)
返回代码/ valueDescription
WAIT_OBJECT_0到(WAIT_OBJECT_0 + nCount - 1)如果bWaitAll为TRUE,则返回值表明,所有指定对象的状态信号。如果bWaitAll为FALSE,则返回值减去WAIT_OBJECT_0表示满意的是等待的对象pHandles数组索引。
WAIT_OBJECT_0 +在dwWakeMask参数中指定的类型nCountNew输入可在线程的输入队列。如PeekMessage,GetMessage函数,并WaitMessage邮件标记为旧的邮件队列。因此,在调用这些函数,随后调用MsgWaitForMultipleObjects人会不会返回,直到指定类型的新的输入到达。
此值也返回后一个系统事件,需要线程的行动,如前景激活的发生。因此,MsgWaitForMultipleObjects可以返回即使没有提供适当的投入,即使dwWakeMask设置为0。如果发生这种情况,调用GetMessage或PeekMessage来处理,然后再尝试调用MsgWaitForMultipleObjects系统事件再次。
WAIT_ABANDONED_0至(WAIT_ABANDONED_0 + nCount - 1)如果bWaitAll为TRUE,则返回值表明,所有指定对象的状态信号,至少其中一个对象是一个被遗弃的互斥对象。如果bWaitAll为FALSE,则返回值减去WAIT_ABANDONED_0表明了一个废弃的互斥对象满意等待pHandles数组索引。对互斥对象的所有权被授予调用线程,而互斥设置为无信号。
假如是互斥保护的持久状态的信息,您应该检查它的一致性。
WAIT_TIMEOUT
258LThe超时时间间隔过去了,由bWaitAll和dwWakeMask参数中指定的条件没有得到满足。
WAIT_FAILED
(DWORD值)0xFFFFFFFFThe函数失败。为了获得更多错误信息,调用GetLastError。
备注
该MsgWaitForMultipleObjects函数确定是否等待标准已得到满足。如果条件没有得到满足,调用线程进入等待,直到标准的条件下等待状态已经达到或超时间隔经过的。
当bWaitAll为TRUE,该函数不修改,直到所有对象的国家指定对象的状态已被设置为信号。例如,一个互斥信号可以,但没有得到线程,直到其他物体的国家所有权,也被设置为信号。与此同时,其他一些线程可能获得互斥体的所有权,从而确定其状态无信号。
当bWaitAll为TRUE,函数的等待是只有在完成所有对象的状态已被设置为输入信号,并已收到的事件。因此,建立bWaitAll为TRUE防止被输入到在pHandles数组中的所有对象的状态处理被设置为信号。为此,如果您设置bWaitAll为TRUE,则应该使用在dwMilliseconds的短期超时值。如果您有一个线程创建的窗口中的所有pHandles数组对象,包括输入事件的dwWakeMask没有指定的超时间隔,系统会死锁等待。这是因为线程创建窗口必须处理消息。 DDE的发送邮件系统中的所有窗口。因此,如果一个线程创建的窗口,不要设置bWaitAll参数以从该线程调用了MsgWaitForMultipleObjects真。
当bWaitAll是FALSE,此功能检查,以便在处理与数组的索引0开始,直到一个对象发出信号。如果多个对象成为暗示,该函数返回首先处理的信号,其目的是数组的索引。
MsgWaitForMultipleObjects不会返回如果在消息队列中指定的类型后,线程调用一个函数来检查队列中未读的投入。这是因为,如PeekMessage,GetMessage,GetQueueStatus功能,WaitMessage检查队列,然后更改队列的状态信息,以便输入不再被认为是新的。随后的调用MsgWaitForMultipleObjects不会返回,直到指定类型的新的输入到达。现有的未读输入(之前收到的最后一次检查的线程队列)被忽略。
函数修改了某些类型的同步对象的状态。改造只对一个或多个对象的信号状态发生所造成的函数返回。例如,一个信号量对象计数减少1。有关详细信息,请参阅个别同步对象文件。
该MsgWaitForMultipleObjects函数可以指定处理的,在下面的对象数组pHandles任何类型:
更改通知
控制台输入
事件
内存资源通知
互斥
工艺
信号量
线
可等待定时器
在QS_ALLPOSTMESSAGE和QS_POSTMESSAGE旗帜不同时被清除。 QS_POSTMESSAGE被清除时调用GetMessage或PeekMessage,不管您是筛选信息。 QS_ALLPOSTMESSAGE被清除时调用GetMessage或未经过滤的信息(wMsgFilterMin和wMsgFilterMax PeekMessage 0)。这可能是有用的当您调用PeekMessage多次获得不同范围的信息。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinuser.h(头文件:winuser.h)
LibraryUser32.lib
DLLUser32.dll
参见
MsgWaitForMultipleObjectsEx
同步功能
等待函数
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==MsgWaitForMultipleObjects Function
Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses. The objects can include input event objects, which you specify using the dwWakeMask parameter.
To enter an alertable wait state, use the MsgWaitForMultipleObjectsEx function.
Syntax
C++
DWORD WINAPI MsgWaitForMultipleObjects(
__in DWORD nCount,
__in const HANDLE *pHandles,
__in BOOL bWaitAll,
__in DWORD dwMilliseconds,
__in DWORD dwWakeMask
);
Parameters
nCount [in]
The number of object handles in the array pointed to by pHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS minus one.
pHandles [in]
An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles of objects of different types. It may not contain multiple copies of the same handle.
If one of these handles is closed while the wait is still pending, the function's behavior is undefined.
The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights .
bWaitAll [in]
If this parameter is TRUE, the function returns when the states of all objects in the pHandles array have been set to signaled and an input event has been received. If this parameter is FALSE, the function returns when the state of any one of the objects is set to signaled or an input event has been received. In this case, the return value indicates the object whose state caused the function to return.
dwMilliseconds [in]
The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses. If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately. If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled.
dwWakeMask [in]
The input types for which an input event object handle will be added to the array of object handles. This parameter can be any combination of the following values.
ValueMeaning
QS_ALLEVENTS
0x04BFAn input, WM_TIMER , WM_PAINT , WM_HOTKEY , or posted message is in the queue.
This value is a combination of QS_INPUT, QS_POSTMESSAGE, QS_TIMER, QS_PAINT, and QS_HOTKEY.
QS_ALLINPUT
0x04FFAny message is in the queue.
This value is a combination of QS_INPUT, QS_POSTMESSAGE, QS_TIMER, QS_PAINT, QS_HOTKEY, and QS_SENDMESSAGE.
QS_ALLPOSTMESSAGE
0x0100A posted message is in the queue.
This value is cleared when you call GetMessage or PeekMessage without filtering messages.
QS_HOTKEY
0x0080A WM_HOTKEY message is in the queue.
QS_INPUT
0x407An input message is in the queue.
This value is a combination of QS_MOUSE, QS_KEY, and QS_RAWINPUT.
Windows 2000: This value does not include QS_RAWINPUT.
QS_KEY
0x0001A WM_KEYUP , WM_KEYDOWN , WM_SYSKEYUP , or WM_SYSKEYDOWN message is in the queue.
QS_MOUSE
0x0006A WM_MOUSEMOVE message or mouse-button message (WM_LBUTTONUP, WM_RBUTTONDOWN , and so on).
This value is a combination of QS_MOUSEMOVE and QS_MOUSEBUTTON.
QS_MOUSEBUTTON
0x0004A mouse-button message (WM_LBUTTONUP, WM_RBUTTONDOWN, and so on).
QS_MOUSEMOVE
0x0002A WM_MOUSEMOVE message is in the queue.
QS_PAINT
0x0020A WM_PAINT message is in the queue.
QS_POSTMESSAGE
0x0008A posted message is in the queue.
This value is cleared when you call GetMessage or PeekMessage, whether or not you are filtering messages.
QS_RAWINPUT
0x0400A raw input message is in the queue. For more information, see Raw Input .
Windows 2000: This value is not supported.
QS_SENDMESSAGE
0x0040A message sent by another thread or application is in the queue.
QS_TIMER
0x0010A WM_TIMER message is in the queue.

Return Value
If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values. (Note that WAIT_OBJECT_0 is defined as 0 and WAIT_ABANDONED_0 is defined as 0x00000080L.)
Return code/valueDescription
WAIT_OBJECT_0 to (WAIT_OBJECT_0 + nCount– 1)If bWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled. If bWaitAll is FALSE, the return value minus WAIT_OBJECT_0 indicates the pHandles array index of the object that satisfied the wait.
WAIT_OBJECT_0 + nCountNew input of the type specified in the dwWakeMask parameter is available in the thread's input queue. Functions such as PeekMessage, GetMessage, and WaitMessage mark messages in the queue as old messages. Therefore, after you call one of these functions, a subsequent call to MsgWaitForMultipleObjects will not return until new input of the specified type arrives.
This value is also returned upon the occurrence of a system event that requires the thread's action, such as foreground activation. Therefore, MsgWaitForMultipleObjects can return even though no appropriate input is available and even if dwWakeMask is set to 0. If this occurs, call GetMessage or PeekMessage to process the system event before trying the call to MsgWaitForMultipleObjects again.
WAIT_ABANDONED_0 to (WAIT_ABANDONED_0 + nCount– 1)If bWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled and at least one of the objects is an abandoned mutex object. If bWaitAll is FALSE, the return value minus WAIT_ABANDONED_0 indicates the pHandles array index of an abandoned mutex object that satisfied the wait. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled.
If the mutex was protecting persistent state information, you should check it for consistency.
WAIT_TIMEOUT
258LThe time-out interval elapsed and the conditions specified by the bWaitAll and dwWakeMask parameters were not satisfied.
WAIT_FAILED
(DWORD)0xFFFFFFFFThe function has failed. To get extended error information, call GetLastError .

Remarks
The MsgWaitForMultipleObjects function determines whether the wait criteria have been met. If the criteria have not been met, the calling thread enters the wait state until the conditions of the wait criteria have been met or the time-out interval elapses.
When bWaitAll is TRUE, the function does not modify the states of the specified objects until the states of all objects have been set to signaled. For example, a mutex can be signaled, but the thread does not get ownership until the states of the other objects have also been set to signaled. In the meantime, some other thread may get ownership of the mutex, thereby setting its state to nonsignaled.
When bWaitAll is TRUE, the function's wait is completed only when the states of all objects have been set to signaled and an input event has been received. Therefore, setting bWaitAll to TRUE prevents input from being processed until the state of all objects in the pHandles array have been set to signaled. For this reason, if you set bWaitAll to TRUE, you should use a short timeout value in dwMilliseconds. If you have a thread that creates windows waiting for all objects in the pHandles array, including input events specified by dwWakeMask, with no timeout interval, the system will deadlock. This is because threads that create windows must process messages. DDE sends message to all windows in the system. Therefore, if a thread creates windows, do not set the bWaitAll parameter to TRUE in calls to MsgWaitForMultipleObjects made from that thread.
When bWaitAll is FALSE, this function checks the handles in the array in order starting with index 0, until one of the objects is signaled. If multiple objects become signaled, the function returns the index of the first handle in the array whose object was signaled.
MsgWaitForMultipleObjects does not return if there is unread input of the specified type in the message queue after the thread has called a function to check the queue. This is because functions such as PeekMessage , GetMessage, GetQueueStatus , and WaitMessage check the queue and then change the state information for the queue so that the input is no longer considered new. A subsequent call to MsgWaitForMultipleObjects will not return until new input of the specified type arrives. The existing unread input (received prior to the last time the thread checked the queue) is ignored.
The function modifies the state of some types of synchronization objects. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one. For more information, see the documentation for the individual synchronization objects.
The MsgWaitForMultipleObjects function can specify handles of any of the following object types in the pHandles array:
Change notification
Console input
Event
Memory resource notification
Mutex
Process
Semaphore
Thread
Waitable timer
The QS_ALLPOSTMESSAGE and QS_POSTMESSAGE flags differ in when they are cleared. QS_POSTMESSAGE is cleared when you call GetMessage or PeekMessage , whether or not you are filtering messages. QS_ALLPOSTMESSAGE is cleared when you call GetMessage or PeekMessage without filtering messages (wMsgFilterMin and wMsgFilterMax are 0). This can be useful when you call PeekMessage multiple times to get messages in different ranges.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinuser.h (include Windows.h)
LibraryUser32.lib
DLLUser32.dll
See Also
MsgWaitForMultipleObjectsEx
Synchronization Functions
Wait Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms684242(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 9:21:35