Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Sep : AllocConsole + CreateProcess + ReadConsoleOutput
| Subject: | AllocConsole + CreateProcess + ReadConsoleOutput |
| Posted by: | "Thomas" (tomschneid..@trash-mail.de) |
| Date: | Sun, 2 Sep 2007 09:20:40 |
This is (in short) the code that works:
AllocConsole;
CreateProcess(...,PChar(MyCmdLineApp),...,ProcessInfo);
repeat
GetExitCodeProcess(ProcessInfo.hProcess,dwExitCode);
until (dwExitCode<>STILL_ACTIVE);
ReadConsoleOutput(...);
AnalyseConOut;
DoSomething;
FreeConsole;
For some reasons now I can _not_ use AllocConsole/FreeConsole (or
redirect handles). So I tried to do it with
CreateProcess(...,PChar(MyCmdLineApp),...,CREATE_NEW_CONSOLE,...);
Problem: The console window closes immediately after the thread/process
has finished. But I cannot call ReadConsoleOutput before because for the
call of AnalyseConOut I need _all_ that was written to the console window.
Is there a way to get my hands on that what's in the console window before
it is closed?
Any help is appreciated. Thanks in advance.
Tom