thank you Martin, I obviously failed somewhere. I did try FILE_FLAG_OVERLAPPED and everything attached to it, but the input is already opened, so i get an error. I'll try somewhat later when real life gives me a new break. Off for now. Thierry ----- Mail Original ----- De: "Martin Schreiber" <mse00...@gmail.com> À: fpc-pascal@lists.freepascal.org Envoyé: Samedi 10 Décembre 2011 18h50:09 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [fpc-pascal] How to poll for a byte in Input?
On 12/10/2011 02:58 PM, tcoq wrote: > Chad, > Thank you very much. I will try your approach, as I'm interested in the > piping. > > I also did some experimenting with SetConsoleMode, and also with > SetFileAttributes, and with ReadFileEx. But no answer there. Still blocks. > IIRC non blocking pipes are difficult on Windows. MSEgui uses a separate thread in tpipereader for simulating non blocking pipes on Windows. http://gitorious.org/mseide-msegui http://gitorious.org/mseide-msegui/mseide-msegui/blobs/master/lib/common/kernel/msepipestream.pas Asynchronous IO on Windows is done by adding FILE_FLAG_OVERLAPPED to createfile() parameters and a toverlapped with an event object in readfile(). http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=VS.85%29.aspx getoverlappedresult() can then be called with toverlapped or waitforsingleobject() with toverlapped.event as parameter. http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032%28v=vs.85%29.aspx Don't forget to create and free the event object! An example with FILE_FLAG_OVERLAPPED is here http://gitorious.org/mseide-msegui/mseide-msegui/blobs/master/lib/common/serialcomm/msecommport.pas All IIRC! ;-) Martin _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal