Connecting Tech Pros Worldwide Forums | Help | Site Map

How to capture the result of winexec()

Camel
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi All,

I am doing my Visual C++ homework. My program requires to build a GUI and
ping a host, then display the result. I called winexec("ping 192.168.0.1"),
however it executed in DOS window. How can I capture the ping result?

Thanks in advance.



Phlip
Guest
 
Posts: n/a
#2: Jul 23 '05

re: How to capture the result of winexec()


Camel wrote:[color=blue]
>
> I am doing my Visual C++ homework. My program requires to build a GUI and
> ping a host, then display the result. I called winexec("ping[/color]
192.168.0.1"),[color=blue]
> however it executed in DOS window. How can I capture the ping result?[/color]

popen("ping...");

You will get better results in a VC++ newsgroup; raw C++ specifies
incomplete libraries (compared to, say, Java), so all things to do with
pinging and pipes refer to the libraries that come with your compiler.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


Abecedarian
Guest
 
Posts: n/a
#3: Jul 23 '05

re: How to capture the result of winexec()


Phlip wrote:[color=blue]
> Camel wrote:[color=green]
> >
> > I am doing my Visual C++ homework. My program requires to build a[/color][/color]
GUI and[color=blue][color=green]
> > ping a host, then display the result. I called winexec("ping[/color]
> 192.168.0.1"),[color=green]
> > however it executed in DOS window. How can I capture the ping[/color][/color]
result?[color=blue]
>
> popen("ping...");[/color]

or read:
http://msdn.microsoft.com/library/de...and_output.asp
[color=blue]
> You will get better results in a VC++ newsgroup;[/color]

e.g.:
http://www.codeproject.com/script/co...p?forumid=1647

::A::

Phlip
Guest
 
Posts: n/a
#4: Jul 23 '05

re: How to capture the result of winexec()


Abecedarian wrote:
[color=blue]
> or read:
>[/color]
http://msdn.microsoft.com/library/de...and_output.asp

I keep trying that, and it keeps kicking my ass.
[color=blue]
>sigh<[/color]

To the OP: Use as many POSIX-style things as possible. If a popen or _popen
is available, use it in preference to mucking with raw Win32 file HANDLE
types. popen exists to solve some of the problems that low level stuff
causes.

Use either popen or system("ping ... >yo.txt"). Then read the contents of
yo.txt. I'm not kidding.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


Closed Thread