Connecting Tech Pros Worldwide Help | Site Map

How to capture the result of winexec()

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 03:58 AM
Camel
Guest
 
Posts: n/a
Default How to capture the result of winexec()

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.



  #2  
Old July 23rd, 2005, 03:58 AM
Phlip
Guest
 
Posts: n/a
Default 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


  #3  
Old July 23rd, 2005, 03:58 AM
Abecedarian
Guest
 
Posts: n/a
Default 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::

  #4  
Old July 23rd, 2005, 03:58 AM
Phlip
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.