[fpc-pascal] TFileStream and stdin - how to make this work?

Bernd Kreuss prof7bit at googlemail.com
Sun Oct 3 23:42:22 CEST 2010


On 03.10.2010 16:16, Honza wrote:

> See also sockets:
> 
> http://wiki.lazarus.freepascal.org/Sockets
> 
> and pipes:
> 
> http://www.freepascal.org/docs-html/fcl/pipes/tinputpipestream.html
> 
> The TInputPipeStream has a "property NumBytesAvailable: DWord; [r]
> Number of bytes available for reading.", which may enable the polling.

I'm currently evaluating what is the easiest (least complicated) way of
communicating with a separate executable that is only used to display
some GUI forms to display some data and a few GUI elements to give input
to the main application. It is some kind of frontend to a process that
cannot have its own GUI (the other half of my code resides in a DLL and
i haven't found any *reliable* and robust way of creating a LCL GUI
directly from within this library because I have no control over the
application's main thread, all I have are function calls from the main
application on certain events that all come from different threads).

I have a (buggy) prototype that tries to create its own GUI thread in
the DLL and an ugly mess of QueueAsyncCall() to communicate with it and
a homemade event loop but it will still randomly crash ---> no idea why,
not reliable.

And I have another (already working) prototype which uses
tSimpleIPCServer and Client to communicate with a separately started
executable, this works quite nice but i thought i could make it even
easier and more compact.

Now I have a third prototype almost complete that uses TProcess to start
the exe from the dll and this is why I needed the stdio stuff. I have
now made a separate thread to listen on stdio and the synchronize()
stuff seems not so complicated as I initially thought. Overall I
currently like the TProcess/stdio method the most.

Bernd



More information about the fpc-pascal mailing list