Re: Running external program and capture output Shellexecute?
- From: "Marcel" <Mvamstel@xxxxxxxxxxx>
- Date: Mon, 30 Jan 2006 11:20:37 +0100
Hi,
Jochen, your code worked for me only the rediriction of the output seems
to go wrong. When I run the program I want to call on the command prompt
output is created on the screen, but when I try to redirect it in the
way you suggest the output string remains empty.
I tried to redirect from StandardError, and I also tried to move the
WaitforExit to after the ReadToEnd clause, both without succes.
Any ideas on this?
Greetings,
Marcel
-----Original Message-----
From: Jochen Kalmbach [MVP] [mailto:nospam-Jochen.Kalmbach@xxxxxxxxx]
Posted At: woensdag 25 januari 2006 15:36
Posted To: microsoft.public.vc.language
Conversation: Running external program and capture output Shellexecute?
Subject: Re: Running external program and capture output Shellexecute?
Hi Marcel!
> Hi,
>
> I'm new here and I don't know if I'm posting this in the correct
place.
>
> I'm using Visual Studio 2003 and I have to create a windows
> application, so I use the .NET windows forms application to do this.
> My program has to use the Spin model checker, which I want to call as
> an external program. So I want to run that program in a dos-box from
> within my application and when it exits I want to read all the output
> it has generated to use in my application.
> Is there a way to do this?
If you do Windows-Forms you should also use the managed-API to do this
work...
#undef MessageBox
System::Diagnostics::ProcessStartInfo *si = new
System::Diagnostics::ProcessStartInfo();
si->UseShellExecute = false;
si->WorkingDirectory = S"C:\\";
si->FileName = "C:\\program.exe";
si->Arguments = "args";
si->RedirectStandardOutput = true;
System::Diagnostics::Process *p =
System::Diagnostics::Process::Start(si);
p->WaitForExit();
System::String *output = p->StandardOutput->ReadToEnd();
System::Windows::Forms::MessageBox::Show(output);
PS: A better newsgroup is
microsoft.public.dotnet.languages.vc
--
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
.
- References:
- Re: Running external program and capture output Shellexecute?
- From: Jochen Kalmbach [MVP]
- Re: Running external program and capture output Shellexecute?
- Prev by Date: Re: How to get the command line arguments of other running process
- Next by Date: Re: How to get the command line arguments of other running process
- Previous by thread: Re: Running external program and capture output Shellexecute?
- Next by thread: Re: Running external program and capture output Shellexecute?
- Index(es):
Relevant Pages
|