Can I display the result of a loop in the console window in a VCL application for debugging purposes?
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
- DBGrid - How to set an individual background color
相关文章
- Best way to implement MVVM bindings (View <-> V
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- HelpInsight documentation in Delphi 2007
- Can RTTI interrogate types from project code at de
- What specifically causes EPrivilege to be raised?
- Equivalent to designer guidelines in code
Delphi has got an option for this, check "Generate console application" in the linker options for the project. Standard I/O will be directed to a console window which will accompany your GUI application. Then you can use
Writeln
etc. as you normally would.Read Output (or Input) from the docs:
In Windows, the simplest way to output debug information is to use
OutputDebugString()
and then use an application able to receive that output. The event viewer in the Delphi IDE itself is able to receive that input, or you can use the DebugView application from SysInternals to get output on a system that hasn't the IDE installed. AFAIK, GExperts has a similar tool too. That's because a GUI application has not by default a console where to write output, otherwise you have to create one (see Gerry's answer).One of
OutputDebugString()
's advantages is that the application will work without problems even if a call slips into a release build (or is if left there intentionally), but be careful then to not output sensitive information, because they can be read using one of the tools above.You could also create an ad-hoc form (that is, with a memo control) and route output there.
There are also advanced logging facilities like SmartInspect, CodeSite and others.
If you wrote the console application, you can try OutputDebugString function in the console application (I didn't try).
Or you can capture the output of the console application like in Capture the output from a DOS (command/console) Window .
Also, you can check Console Application Runner Classes. I use these classes. I think they are great.
The simplest way is to compile as a console application, but put the normal application framework code back in the dpr.
A slightly more complex way is to use the Windows API AllocConsole call:
This method has the (usually) disadvantage of creating a new console if you are calling from the command line. From memory getting redirection to work requires some more code as well. The advantage is that you can decide to allocate the console at run-time, rather than compile time.