• 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.
  • Posts

    • WSCC - Windows System Control Center 10.0.0.8 by Razvan Serea Windows System Control Center is a free, portable program that allows you to install, update, execute and organize the utilities from various system utility suites. WSCC can install and update the supported utilities automatically. Alternatively, WSCC can use the http protocol to download and run the programs. WSCC is portable, installation is not required. Extract the content of the downloaded zip archive to any directory on your computer. Free for personal use. The setup packages and updates are downloaded directly from their author's website! This edition of WSCC supports the following utility suites: Windows Sysinternals Suite (including support for "Sysinternals Live" service) NirSoft Utilities Mitec and more... WSCC - Windows System Control Center 10.0.0.8 changelog: Update Manager: scheduled updates will run even if WSCC is already running minor user interface improvements Download: WSCC (64-bit) | 6.9 MB (Free for personal use) Download: WSCC (32-bit) | 6.2 MB View: WSCC Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • It seems I was wrong. Modifying the registry manually does not have an effect at all, even after restart. Just use ViveTool for now. I'm going to need to investigate this...
    • Just a small addition - If you're running the command from Powershell, the syntax is: ./vivetool /enable /id:41073112
    • The weak US Governments and DoJ have never been good enough at regulating greedy giants like Apple and Microsoft. These companies want your money yet they will take away your useful features and choices too to sell you the "next upgrade" and no Govt acts against that.
  • Recent Achievements

    • Posting Machine
      Fiza Ali earned a badge
      Posting Machine
    • One Year In
      WaynesWorld earned a badge
      One Year In
    • First Post
      chriskinney317 earned a badge
      First Post
    • Week One Done
      Nullun earned a badge
      Week One Done
    • First Post
      sultangris earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      182
    2. 2
      snowy owl
      130
    3. 3
      ATLien_0
      127
    4. 4
      Xenon
      119
    5. 5
      +Edouard
      89
  • Tell a friend

    Love Neowin? Tell a friend!