How to debug a Delphi redirected application

I have a console application that crashes with an I / O 6 error when the output is redirected to a file. This is probably due to the fact that the console application changes the color of the text, which does not make much sense in the file.

  • It works: c:\dir\app.exe
  • Failure: c:\dir\app.exe >out.txt

When I set >out.txtas a parameter in the IDE ( run\parameters\parameters\), I just get >out.txtas a parameter.

How to debug an application using stdout redirected to a file instead of a console?

+5
source share
3 answers

The redirection is performed by the command line interpreter; in windows it is cmd.exe

, cmd.exe propers, , :

cmd.exe/c "yourapplication.exe > ​​redirect.txt"

IDE , cmd.exe - (Run/Parameters):

Run / Parameters dialog

, , cmd.exe( Project/Load) "Run to first source" :

Load process dialog

... .

+12

:

  • ReadLn;, Delphi

  • ( p > out.txt)

  • Delphi, (Run | Attach to Process...), ,

: ​​ :

asm
  int 3
end;
+2

Make sure it fails due to directory permissions. Fully qualify the output file path to where you might be able to write. Otherwise, Windows7 may play games with a directory. (VirtualStore material).

0
source

All Articles