网站首页  词典首页

请输入您要查询的函数:

 

术语 waitcommevent
释义 WaitCommEvent
语法:
C++
BOOL WINAPI WaitCommEvent(
__in HANDLE hFile,
__out LPDWORD lpEvtMask,
__in LPOVERLAPPED lpOverlapped
);
WaitCommEvent函数
等待一个事件发生在指定的通信设备。该受此事件的监测功能设置,包含在设备句柄相关的事件掩码。
参数
hFile [in]
一个句柄,通信设备。 CreateFile函数返回此句柄。
lpEvtMask [out]
一个变量,它接收面具,说明事件的类型发生指针。如果发生错误,该值为零,否则,它是下列值之一。
ValueMeaning
EV_BREAK
0x0040A打破上检测输入。
EV_CTS
0x0008The中旅(明确到发送)改变了状态的信号。
EV_DSR
0x0010The DSR(数据设置就绪)信号改变状态。
EV_ERR
0x0080A线状态错误发生。线路状态错误CE_FRAME,CE_OVERRUN和CE_RXPARITY。
EV_RING
0x0100A环指标检测。
EV_RLSD
0x0020The RLSD(接收线信号检测)信号改变状态。
EV_RXCHAR
0x0001A的性质是接获和输入缓冲区内。
EV_RXFLAG
0x0002The事件的性质是接获和输入缓冲区内。事件中指定的字符设备的DCB结构,适用于使用SetCommState函数到串行端口。
EV_TXEMPTY
0x0004The在输出缓冲区的最后一个字符被送往。
lpOverlapped [in]
一个OVERLAPPED结构的指针。这种结构则需要hFile是与FILE_FLAG_OVERLAPPED打开。
如果hFile开幕时FILE_FLAG_OVERLAPPED的lpOverlapped参数必须是NULL。它必须指向一个有效的OVERLAPPED结构。如果hFile开幕时FILE_FLAG_OVERLAPPED和lpOverlapped为NULL,函数可以错误地报告说,操作完成。
如果hFile开幕时FILE_FLAG_OVERLAPPED和lpOverlapped不为NULL,WaitCommEvent是作为重叠操作执行。在这种情况下,OVERLAPPED结构必须包含一个句柄手动重置事件对象(通过使用CreateEvent函数创建)。
如果hFile不符合FILE_FLAG_OVERLAPPED打开,WaitCommEvent不会返回,直到指定的事件或出现的错误之一。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
在WaitCommEvent函数监控一个特定的通信资源的事件。要设置和查询的通讯资源当前事件掩码,使用SetCommMask和GetCommMask功能。
如果重叠操作不能立即完成,该函数返回FALSE并GetLastError函数返回ERROR_IO_PENDING,表明这一行动是在后台执行。当发生这种情况,系统设置重叠结构的hEvent成员,未暗示之前WaitCommEvent返回状态,然后它设置到信号状态时,指定的事件或出现的错误之一。调用进程可以使用函数来确定等待事件对象的状态,然后使用GetOverlappedResult函数来确定的WaitCommEvent操作的结果之一。 GetOverlappedResult报告的成功或失败的操作,和变量指出的lpEvtMask参数设置为显示事件发生。
如果一个进程试图改变设备句柄使用SetCommMask函数的事件掩码,而一个重叠WaitCommEvent操作正在进行中,WaitCommEvent立即返回。该变量指出的lpEvtMask参数设置为零。
实例
有关示例,请参阅监视通信事件。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
通讯功能
通信资源
CreateFile
二氯苯
GetCommMask
GetOverlappedResult
的OVERLAPPED
SetCommMask
SetCommState
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==WaitCommEvent Function
Waits for an event to occur for a specified communications device. The set of events that are monitored by this function is contained in the event mask associated with the device handle.
Syntax
C++
BOOL WINAPI WaitCommEvent(
__in HANDLE hFile,
__out LPDWORD lpEvtMask,
__in LPOVERLAPPED lpOverlapped
);
Parameters
hFile [in]
A handle to the communications device. The CreateFile function returns this handle.
lpEvtMask [out]
A pointer to a variable that receives a mask indicating the type of event that occurred. If an error occurs, the value is zero; otherwise, it is one of the following values.
ValueMeaning
EV_BREAK
0x0040A break was detected on input.
EV_CTS
0x0008The CTS (clear-to-send) signal changed state.
EV_DSR
0x0010The DSR (data-set-ready) signal changed state.
EV_ERR
0x0080A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY.
EV_RING
0x0100A ring indicator was detected.
EV_RLSD
0x0020The RLSD (receive-line-signal-detect) signal changed state.
EV_RXCHAR
0x0001A character was received and placed in the input buffer.
EV_RXFLAG
0x0002The event character was received and placed in the input buffer. The event character is specified in the device's DCB structure, which is applied to a serial port by using the SetCommState function.
EV_TXEMPTY
0x0004The last character in the output buffer was sent.

lpOverlapped [in]
A pointer to an OVERLAPPED structure. This structure is required if hFile was opened with FILE_FLAG_OVERLAPPED.
If hFile was opened with FILE_FLAG_OVERLAPPED, the lpOverlapped parameter must not be NULL. It must point to a valid OVERLAPPED structure. If hFile was opened with FILE_FLAG_OVERLAPPED and lpOverlapped is NULL, the function can incorrectly report that the operation is complete.
If hFile was opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, WaitCommEvent is performed as an overlapped operation. In this case, the OVERLAPPED structure must contain a handle to a manual-reset event object (created by using the CreateEvent function).
If hFile was not opened with FILE_FLAG_OVERLAPPED, WaitCommEvent does not return until one of the specified events or an error occurs.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
The WaitCommEvent function monitors a set of events for a specified communications resource. To set and query the current event mask of a communications resource, use the SetCommMask and GetCommMask functions.
If the overlapped operation cannot be completed immediately, the function returns FALSE and the GetLastError function returns ERROR_IO_PENDING, indicating that the operation is executing in the background. When this happens, the system sets the hEvent member of the OVERLAPPED structure to the not-signaled state before WaitCommEvent returns, and then it sets it to the signaled state when one of the specified events or an error occurs. The calling process can use one of the wait functions to determine the event object's state and then use the GetOverlappedResult function to determine the results of the WaitCommEvent operation. GetOverlappedResult reports the success or failure of the operation, and the variable pointed to by the lpEvtMask parameter is set to indicate the event that occurred.
If a process attempts to change the device handle's event mask by using the SetCommMask function while an overlapped WaitCommEvent operation is in progress, WaitCommEvent returns immediately. The variable pointed to by the lpEvtMask parameter is set to zero.
Examples
For an example, see Monitoring Communications Events .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Communications Functions
Communications Resources
CreateFile
DCB
GetCommMask
GetOverlappedResult
OVERLAPPED
SetCommMask
SetCommState
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363479(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 13:25:45