Click here to Skip to main content
15,917,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Efficient Thread Synchronization Object? Pin
valikac19-Aug-04 5:56
valikac19-Aug-04 5:56 
AnswerRe: Efficient Thread Synchronization Object? Pin
gamitech19-Aug-04 11:41
gamitech19-Aug-04 11:41 
GeneralRe: Efficient Thread Synchronization Object? Pin
aufeuer19-Aug-04 14:32
aufeuer19-Aug-04 14:32 
GeneralRe: Efficient Thread Synchronization Object? Pin
Blake Miller30-Aug-04 6:21
Blake Miller30-Aug-04 6:21 
GeneralBluetooth related question ! Pin
Cedric Moonen18-Aug-04 21:15
Cedric Moonen18-Aug-04 21:15 
GeneralRe: Bluetooth related question ! Pin
Antti Keskinen18-Aug-04 23:40
Antti Keskinen18-Aug-04 23:40 
GeneralRe: Bluetooth related question ! Pin
Cedric Moonen18-Aug-04 23:50
Cedric Moonen18-Aug-04 23:50 
GeneralRe: Bluetooth related question ! Pin
Antti Keskinen19-Aug-04 1:33
Antti Keskinen19-Aug-04 1:33 
Solution: overlapped I/O.

The last parameter of WriteFile is a pointer to an OVERLAPPED structure that specifies the semantics of an overlapped write operation. This type of an operation is event-driven: when the WriteFile begins, it clears the event flag. When WriteFile finishes, it returns. When the I/O transaction is completed (bytes written), the overlapped flag is raised.

The only necessity is that you open the COM port by using FILE_FLAG_OVERLAPPED specification. Overlapped port access is a tid-bit different from the standard one, but needs to be used in this case. See the OVERLAPPED structure in MSDN for more information.

The basic approach is
1. Create an event object by using CreateEvent
2. Set this event handle into the OVERLAPPED::hEvent member
3. Open the communications port, specifying FILE_FLAG_OVERLAPPED
4. Call WriteFile, specifying the OVERLAPPED structure as the last parameter. WriteFile returns immediately.
5. To determine if the writing was succesfull (if there is a device), call WaitForSingleObject, specifying a suitable time-out. If the event is fired (WaitForSingleObject returns WAIT_OBJECT_0), then the writing was succesfull. If return value is WAIT_TIMEOUT, the timeout was reached.
6. Take appropriate action.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Bluetooth related question ! Pin
Cedric Moonen19-Aug-04 1:45
Cedric Moonen19-Aug-04 1:45 
Generalthread affinity Pin
User 58385218-Aug-04 20:27
User 58385218-Aug-04 20:27 
GeneralRe: thread affinity Pin
Neville Franks19-Aug-04 1:32
Neville Franks19-Aug-04 1:32 
GeneralRe: thread affinity Pin
User 58385219-Aug-04 15:51
User 58385219-Aug-04 15:51 
GeneralAbut dialogs skins Pin
zahid_ash18-Aug-04 20:05
zahid_ash18-Aug-04 20:05 
GeneralRe: Abut dialogs skins Pin
Antti Keskinen18-Aug-04 23:44
Antti Keskinen18-Aug-04 23:44 
GeneralRe: Abut dialogs skins Pin
zahid_ash19-Aug-04 0:27
zahid_ash19-Aug-04 0:27 
GeneralRe: Abut dialogs skins Pin
Antti Keskinen19-Aug-04 1:36
Antti Keskinen19-Aug-04 1:36 
GeneralStrange Error during execution Pin
Paolo Ponzano18-Aug-04 20:02
Paolo Ponzano18-Aug-04 20:02 
GeneralRe: Strange Error during execution Pin
Indrawati18-Aug-04 20:59
Indrawati18-Aug-04 20:59 
GeneralRe: Strange Error during execution Pin
mahade118-Aug-04 21:29
mahade118-Aug-04 21:29 
GeneralDesktop sharing application in vc++.net Pin
Member 69638018-Aug-04 19:04
Member 69638018-Aug-04 19:04 
Generalchange IP address Pin
Member 130718218-Aug-04 17:29
Member 130718218-Aug-04 17:29 
GeneralRe: change IP address Pin
Christian Graus18-Aug-04 17:50
protectorChristian Graus18-Aug-04 17:50 
GeneralRe: change IP address Pin
Member 130718218-Aug-04 18:21
Member 130718218-Aug-04 18:21 
QuestionDoes an application know in which folder it is stored? Pin
Miss Caprice18-Aug-04 17:10
Miss Caprice18-Aug-04 17:10 
AnswerRe: Does an application know in which folder it is stored? Pin
PJ Arends18-Aug-04 17:28
professionalPJ Arends18-Aug-04 17:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.