On Thursday, January 13, 2011 21:47 Bo Berglund wrote: > I need to build a GUI application, which should act as a simple-to-use > front-end to a Windows console program. > The console program accepts a number of different commands, which are > specified on its command line as parameters separated by spaces. > When the console program is started with these parameters it performs > its task and then exits.
> The command line parameters are rather complex and this is why I would > like to build the GUI application in Delphi7 so I can present a > comfortable view of it. > So now I need it to do the following: > 1) Run the console program with the given parameters. > 2) Read back the output of the console program (it will be printed in > the console). > 3) Detect when the console program asks something and let the user > read this in the GUI app and then respond to it by typing in the GUI. > In the past (Using Delphi) and for other reasons I created a few > helpers which I called ExecStart and ExecWait. Both of these starts a > program, but the Wait variation also waits until the program exits. > I used CreateProcess to start the program and WaitForSingleObject to > check if it finished OK using its handle. > So with ExecStart I can start a program with command line parameters > all right, but how do I pick up the data printed to the console by the > program while it runs? > And how do I enter new input that the program may require when it does > not finish execution? > Any pointers to how this can be done appreciated. Sure. uses process; --> TProcess does everything you need; from waiting, to piping. Have fun ;-) -- Best Regards, Andreas -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
