Board index » cppbuilder » Process spawning and communication

Process spawning and communication


2005-09-23 03:03:36 PM
cppbuilder3
Morning Folks.
I'm writing an application that needs to be able to execute dos batch files
and other executables. I want to have the output from these redirected into
a visual component within my app, such as TMemo.
In a unix app, I'd have used fork and execv. In Borland, I've been looking
at "spawnlp" call in process.h, which does execute the program, but I can't
find any way of redirecting it's standard out.
Any thoughts?
DaveP
 
 

Re:Process spawning and communication

Dave Pugh wrote:
Quote
Morning Folks.

I'm writing an application that needs to be able to execute dos batch
files and other executables. I want to have the output from these
redirected into a visual component within my app, such as TMemo.

In a unix app, I'd have used fork and execv. In Borland, I've been
looking at "spawnlp" call in process.h, which does execute the
program, but I can't find any way of redirecting it's standard out.

Any thoughts?

DaveP
Look up the dup2() function in the C++ Builder help files. The example
shows how to redirect stdout.
 

Re:Process spawning and communication

Hi Dave,
You may have a look at my ProjectMaker tool source code. There's a class
called TConsoleRedirector in tools.cpp. It is multi-threaded and it
supports read events. Look at ProjectMakerForm.cpp how it is used. It
should do everything you want.
Download address:
helene-lange-weg.mine.nu/Rutsch/cppcorner.html
Bye, Oliver
 

{smallsort}

Re:Process spawning and communication

Thanks Guys