На главную

On-line справка по Win32 API

Написать письмо
БЕСПЛАТНАЯ ежедневная online лотерея! Выигрывай каждый день БЕСПЛАТНО!
Список всех статей A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z | Скачать Вниз

WaitCommEvent



The 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.

BOOL WaitCommEvent(

HANDLE hFile, // handle of communications device
LPDWORD lpEvtMask, // address of variable for event that occurred
LPOVERLAPPED lpOverlapped, // address of overlapped structure
);


Parameters

hFile

Identifies the communications device. The CreateFile function returns this handle.

lpEvtMask

Points to a 32-bit 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:

Value Meaning
EV_BREAK A break was detected on input.
EV_CTS The CTS (clear-to-send) signal changed state.
EV_DSR The DSR (data-set-ready) signal changed state.
EV_ERR A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY.
EV_RING A ring indicator was detected.
EV_RLSD The RLSD (receive-line-signal-detect) signal changed state.
EV_RXCHAR A character was received and placed in the input buffer.
EV_RXFLAG The 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 The last character in the output buffer was sent.


lpOverlapped

Points 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 handle was not opened with FILE_FLAG_OVERLAPPED, WaitCommEvent does not return until one of the specified events or an error occurs.



Return Values

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.

See Also

CreateFile, DCB, GetCommMask, GetOverlappedResult, OVERLAPPED, SetCommMask, SetCommState




Пригласи друзей и счет твоего мобильника всегда будет положительным!
Предыдущая статья
 
Сайт Народ.Ру Интернет
Следующая статья
Пригласи друзей и счет твоего мобильника всегда будет положительным!

WaitCommEvent



Функция WaitCommEvent ждет случай, чтобы происходить для определенного устройства связи. Совокупность событий, которая проверена этой функцией содержался в маске случая связанной ручкой устройства.

BOOL WaitCommEvent(

РУЧКА hFile, // ручка устройства связи LPDWORD lpEvtMask, // адреса переменной для случая, что произошедшее LPOVERLAPPED lpOverlapped, // адрес перекрытой структуры
);


Параметры

hFile

Идентифицирует устройство связи. Функция CreateFile возвращает эту ручку.

lpEvtMask

Точки на 32- битовую переменную, которые получают маску, указывающую тип случая, что происходил. Если ошибка происходит, величина нулевая; в противном случае, это - одно из следующего величин:

Значение Величины
EV_BREAK прерывание было обнаружено во вкладе.
EV_CTS CTS сигнала (очистка-посылает) изменял состояние.
EV_DSR DSR сигнала (данные-были установлены-готовым) изменял состояние.
EV_ERR строка-статус ошибки происходила. Строка-статус ошибок - CE_FRAME, CE_OVERRUN, и CE_RXPARITY.
EV_RING кольцевой указатель был обнаружен.
EV_RLSD RLSD сигнала (приемник-строка-сигнал-обнаруживает) изменял состояние.
EV_RXCHAR символ был получен и был установлен в входном буфере.
EV_RXFLAG символ события был получен и был установлен в входном буфере. Символ события определен в структуре устройства DCB, которая приложена к последовательному порту используя функцию SetCommState.
EV_TXEMPTY последний символ в выходном буфере был послан.


lpOverlapped

Точки на ПЕРЕКРЫТУЮ структуру. Эта структура потребовалась если hFile был открыт FILE_FLAG_OVERLAPPED.
Если hFile был открыт FILE_FLAG_OVERLAPPED, lpOverlapped параметр не должен быть НЕДЕЙСТВИТЕЛЕН. Это должно указать на правильную ПЕРЕКРЫТУЮ структуру. Если hFile был открыт FILE_FLAG_OVERLAPPED и lpOverlapped НЕДЕЙСТВИТЕЛЕН, функция может неправильно сообщить, что операция завершенна.
Если hFile был открыт FILE_FLAG_OVERLAPPED и lpOverlapped не НЕДЕЙСТВИТЕЛЕН, WaitCommEvent выполнен как перекрытая операция. В этом случае, ПЕРЕКРЫТАЯ структура должна содержать ручку в руководство-восстановившее объект события (созданное использованием функции CreateEvent).

Если ручка hFile не была открыта FILE_FLAG_OVERLAPPED, WaitCommEvent не возвращается пока одно из определенных событий или ошибка не произойдет.



Обратные Величины

Если функция добивается успеха, обратная величина ненулевая.
Если функция терпит неудачу, обратная величина нулевая. Для того, чтобы расширять информацию ошибки, назовите GetLastError.

Замечания

Функция WaitCommEvent проверяет совокупность событий для определенного ресурса связи. Для того, чтобы устанавливаться и запрос текущая маска события ресурса связи, используйте SetCommMask и функции GetCommMask.
Если перекрытая операция не может завершаться немедленно, функция возвращает ЛОЖЬ и функциональный возврат GetLastError ERROR_IO_PENDING, указывая, что операция выполняется на фоне. Когда это случается, система устанавливает элемент hEvent ПЕРЕКРЫТОЙ структуры на не-сигнализировавшее состояние перед возврат WaitCommEvent, и затем это устанавливает это в сигнальное состояние когда одно из определенных событий или ошибка происходит. Вызов процесса может использовать одну из функций ожидания, чтобы определять объектное состояние события затем использовать функцию GetOverlappedResult, чтобы определять результаты операции WaitCommEvent. GetOverlappedResult СООБЩАЕТ успех или неудачу операции, и переменная указывалась, чтобы параметром lpEvtMask установлен, чтобы указывать событие, что происходил.

Если процесс пытается изменять маску события ручки устройства используя функцию SetCommMask тогда как перекрытая операция WaitCommEvent осуществляется, возврат WaitCommEvent немедленно. Переменная указывалась, чтобы параметром lpEvtMask установлен в нуль.

Смотри Также

CreateFile, DCB, GetCommMask, GetOverlappedResult, ПЕРЕКРЫТОЕ, SetCommMask, SetCommState




Вверх Version 1.3, Oct 26 2010 © 2007, 2010, mrhx Вверх
 mrhx software  Русский перевод OpenGL  Русский перевод Win32 API
 
Используются технологии uCoz