6 Replies - 1272 Views - Last Post: 06 March 2010 - 09:48 AM Rate Topic: -----

#1 Guest_Nerran_*


Reputation:

Receiving output from console Program?

Posted 05 March 2010 - 12:53 PM

Hi there.
I currently got a program which is a simple console program. The Program is printing things like
Result of myfile.ncr is TRUE (100)


Unfortunaly I dont have access to the source code of the Program otherwise I would not have any problem.

Well. Somehow I need to get "Result of myfile.ncr is TRUE (100)" into an char Array. But I don't have any clue how to do that. :(
The Program is being run by ExecuteShell(); and it's hidden.

Compiler: Visual C++ 2008 Professional
(Using MFC for my GUI)

Is This A Good Question/Topic? 0

Replies To: Receiving output from console Program?

#2 Martyn.Rae  Icon User is offline

  • The programming dinosaur
  • member icon

Reputation: 540
  • View blog
  • Posts: 1,406
  • Joined: 22-August 09

Re: Receiving output from console Program?

Posted 05 March 2010 - 01:10 PM

Hi Nerran__, are you the original enigma?

You say

Quote

I currently got a program which is a simple console program. The Program is printing things like

 
Result of myfile.ncr is TRUE (100)



Unfortunaly I dont have access to the source code of the Program otherwise I would not have any problem.


and then you say

Quote

Well. Somehow I need to get "Result of myfile.ncr is TRUE (100)" into an char Array. But I don't have any clue how to do that.
The Program is being run by ExecuteShell(); and it's hidden.

Compiler: Visual C++ 2008 Professional
(Using MFC for my GUI)


Well, you have me totally confused.

a simple console program and (Using MFC for my GUI) in the same post?

and

Unfortunaly I dont have access to the source code of the Program otherwise I would not have any problem and I don't have any clue how to do that.

Anyway, here is your answer:

char Array[] = { "Result of myfile.ncr is TRUE (100)" };



The Array now contains the text you needed. You just need to write the rest of the console program using MFC, using the talent that you say you have/don't have.

On a serious note, perhaps you could tell us what the real problem is?
Was This Post Helpful? 0
  • +
  • -

#3 Zoopa  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 22-February 10

Re: Receiving output from console Program?

Posted 05 March 2010 - 01:25 PM

I guess he's got an MFC app that starts a console application and he wants to use the console app's output in his own program.

This post has been edited by Zoopa: 05 March 2010 - 01:26 PM

Was This Post Helpful? 0
  • +
  • -

#4 Guest_Nerran_*


Reputation:

Re: Receiving output from console Program?

Posted 05 March 2010 - 01:37 PM

View PostZoopa, on 05 March 2010 - 12:25 PM, said:

I guess he's got an MFC app that starts a console application and he wants to use the console app's output in his own program.

Yep sorry for the inexact describtion. Here again:
I have two programs. One is a simple console program, call it console.exe. The other one is a program with GUI using MFC, call it gui.exe. Now I need to get information from console.exe which will be used in gui.exe.
I know how to run the console.exe and it runs perfectly. But I don't know how to get the information needed out of the console of console.exe
Was This Post Helpful? 0

#5 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Receiving output from console Program?

Posted 05 March 2010 - 01:47 PM

SO basically you need to get the stdout from the program and open it. This is called a pipe. You can start reading about them here on MSDN.

An easy to do this is just to use the command line to map stdout from console.exe to stdin of gui.exe -- but to do this from an icon might be tricky...

so using the techniques shown in the link would probably be best for what you are doing.
Was This Post Helpful? 0
  • +
  • -

#6 Munawwar  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 162
  • View blog
  • Posts: 457
  • Joined: 20-January 10

Re: Receiving output from console Program?

Posted 05 March 2010 - 01:49 PM

You will have to use pipes. I found some information here.This isn't MFC unfortunatly.
Was This Post Helpful? 0
  • +
  • -

#7 Guest_Nerran_*


Reputation:

Re: Receiving output from console Program?

Posted 06 March 2010 - 09:48 AM

Thanks. I got it halfway. In fact I'm stuck at creating a pipe to another process (Which is NOT a copy of the main process.(gui.exe -> gui.exe works. but gui.exe <- console.exe doesnt). All information I got is how to create a pipe to a copy of the "host" process.
Was This Post Helpful? 0

Page 1 of 1