• 0

How to capture the output of a console app in BCB


Question

Hi,

I want to be able to launch and capture the output produced by a console application

such as a compiler or whatever it is ran from my program in BCB. Is this hard to do?

Can't I just ShellExecute the executable and then redirect the output to a temporary text file and then just read the text file? If yes, I know in Unix, if I want to re-direct the output you would use the < redirection symbol for example "ls -l < output.txt" What is the symbol for DOS to redirect the output to a text file?

I can achive this via code and then just read the file.

By the way, I am not a Unix/Linux guy, I just know this from Uni...and reading Unix books.

Anyway I have searched the Borland Developer Network but all the samples I found there are written for Delphi (something which I don't have or know too well) and JBuilder too but I was unable to find examples for C++ Builder, the tool that I use.

May someone please show me or hint me how to achieve this? I know I have been asking a lot and you have been of great help so I thank you all for that and so that you know, I do have a book but many specific things like this are not documented.

4 answers to this question

Recommended Posts

  • 0

I think I might have found a solution :) WOW, this is more complicated then what I thought

Check this out!

http://bdn.borland.com/article/0,1410,10387,00.html

UPDADATE: Ok, that's not what I expected. The author there doesn't use VCL, instead, pure command line, back to square one.

Edited by ford_fpv
  • 0

UPDATE 2GUI app can display the errors to the

user, such as in a TMemo or popup MessageBox. Use the hStdOut and hStdError

members of the STARTUPINFO structure for that when calling CreateProcess().

Use CreatePipe() to create an anonymous pipe that you can then pass to

ReadFile();

Getting closer but not close enough

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.