Board index » cppbuilder » execute another Exe and get back information?

execute another Exe and get back information?

I hope you can help me.
I am new to C++
I know how to write programs in Visual Basic and a little bit Pascal
I am using Borland C++Builder 5

What I want to do is to make a programm which executes a console program and
gets back the information the console programm would normaly print in the
dosbox. All this should happen while the user can not see the console
program execute. I only need the Information the program returns.
Does anyone know how to realize this? Please help me.

 

Re:execute another Exe and get back information?


There are a couple of ways of sharing information between programs. One is an
old way, which is writing the information to a file, and the other is the more
modern way, which involves memory mapping. I suggest you look for the subject
"memory mapping" in the Windows SDK or get a book that includes it such as any
one of Jeff Richter's books on the Windows API. The calling program can create
the memory mapped file and the called program, your console program can write
its information to it. After your console program is finished the calling
program can then read the memory mapped file to get its information.

As to creating a console window that does not show, Stefan Hoffmeister gave me
the general answer to this and I will pass it on to you. Look at CreateProcess
which lets you start your console program from within your own program. One of
the many parameters to this call lets you create a console program without its
window showing.

Quote
Jakob Westhoff wrote:
> I hope you can help me.
> I am new to C++
> I know how to write programs in Visual Basic and a little bit Pascal
> I am using Borland C++Builder 5

> What I want to do is to make a programm which executes a console program and
> gets back the information the console programm would normaly print in the
> dosbox. All this should happen while the user can not see the console
> program execute. I only need the Information the program returns.
> Does anyone know how to realize this? Please help me.

Re:execute another Exe and get back information?


On Sun, 9 Apr 2000 21:40:45 +0200, "Jakob Westhoff"

Quote
<jwesth...@online.de> wrote:
>I hope you can help me.
>I am new to C++
>I know how to write programs in Visual Basic and a little bit Pascal
>I am using Borland C++Builder 5

>What I want to do is to make a programm which executes a console program and
>gets back the information the console programm would normaly print in the
>dosbox. All this should happen while the user can not see the console
>program execute. I only need the Information the program returns.
>Does anyone know how to realize this? Please help me.

Depends on how fancy you want to get. I'd just use freopen() to redirect
the console output to a file, spawn...() the console app as a child
process, wait() on the child to finish, and then take what I needed from
the resulting files. Simple, and it leaves the output behind if you need
to examine it.

Pipes would be an option if you wanted to re-do the console program. The
nice thing about freopen() is that the child process doesn't need to be
altered in any way.

I *think* (translation: haven't tried it) that if you spawn the shortcut
instead of the actual .exe file then you can set the options on the
shortcut to run minimized.

--
Rich Webb    Norfolk, VA
raw...@erols.com

Re:execute another Exe and get back information?


I  can't find any information about the CreateProcess Command in my books.
Do you now where to find information?
Or can you give my an example of the Command, just to execute a programm
without showing it to the user.

thx.

Jakob Westhoff

Re:execute another Exe and get back information?


The easiest way I know of is by using the _popen function call.  Then you can use _fgets to read what the process printed.

Quote
"Jakob Westhoff" <jwesth...@online.de> wrote:
>I hope you can help me.
>I am new to C++
>I know how to write programs in Visual Basic and a little bit Pascal
>I am using Borland C++Builder 5

>What I want to do is to make a programm which executes a console program and
>gets back the information the console programm would normaly print in the
>dosbox. All this should happen while the user can not see the console
>program execute. I only need the Information the program returns.
>Does anyone know how to realize this? Please help me.

Re:execute another Exe and get back information?


I thought about that already, but it does not work
If I try to do so, there is always an Access Violation.

Any ideas or sample Code

Re:execute another Exe and get back information?


It's in the Windows SDK help file.

I don't remember the exact parameter that hides the console window but I did
it at my job as a consultant and if I remember, I'll print the code and post
it back on this thread tomorrow.

Quote
Jakob Westhoff wrote:
> I  can't find any information about the CreateProcess Command in my books.
> Do you now where to find information?
> Or can you give my an example of the Command, just to execute a programm
> without showing it to the user.

> thx.

> Jakob Westhoff

Re:execute another Exe and get back information?


WINDOWS SDK? Help File?
Sorry but I have never used it during my programing time with Visual Basic.
Where do I get it.
Or do I have it already and don't know how to open it?

Jakob Westhoff.

Edward Diener <eddie...@abraxis.com> schrieb in im Newsbeitrag:
38F3E704.599E2...@abraxis.com...

Quote
> It's in the Windows SDK help file.

> I don't remember the exact parameter that hides the console window but I
did
> it at my job as a consultant and if I remember, I'll print the code and
post
> it back on this thread tomorrow.

> Jakob Westhoff wrote:

> > I  can't find any information about the CreateProcess Command in my
books.
> > Do you now where to find information?
> > Or can you give my an example of the Command, just to execute a programm
> > without showing it to the user.

> > thx.

> > Jakob Westhoff

Other Threads