Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2003.02.06;
Скачать: [xml.tar.bz2];

Вниз

Есть вопросик   Найти похожие ветки 

 
_saha_   (2003-01-28 21:59) [0]

Привет всем!
Суть вопроса:
пытаюсь написать драйвер для сом-порта,
все отлично, но возникает вопрос чем занять свою программу во время ожидания прихода чего-нибудь в порт.
нашел хорошую функцию waitcomevent, но проблема в том, что прервать ожидание никак низя :(
Может кто подскажет как послать этой функции сообщение что что-то пришло, или может можно как-то перехватить само сообщение о том что что-то произошло. Вот, спасибо.


 
Digitman   (2003-01-29 08:50) [1]


> прервать ожидание никак низя


Ничего подобного. Ожидание можно организовать в асинхронном режима.

Читаем хэлп к ф-ции :

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.



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2003.02.06;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.01 c
3-15521
pave1
2003-01-19 20:47
2003.02.06
Создание индекса для dBase


14-15922
Дремучий
2003-01-20 23:17
2003.02.06
Постучали мне на аську.... :))


9-15385
Zahar
2002-06-09 18:59
2003.02.06
Создание игр на Delphi


14-15870
Opryshok
2003-01-20 05:50
2003.02.06
AudioCD to MP3


1-15656
Alexander Dedusenko
2003-01-27 12:45
2003.02.06
Класс окна





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский