如何写入控制台窗口进行调试

如何写入控制台窗口进行调试

本文介绍了如何写入控制台窗口进行调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用程序中,我可以在控制台窗口中显示一个循环的结果,以进行调试目的?

Can I display the result of a loop in the console window in a VCL application for debugging purposes?

推荐答案

在Windows中,输出调试信息的最简单的方法是使用 OutputDebugString() / code>然后使用能够接收该输出的应用程序。 Delphi IDE本身的事件查看器能够接收该输入,也可以使用获取未安装IDE的系统上的输出。 AFAIK,GExperts也有类似的工具。这是因为GUI应用程序在默认情况下没有控制台写入输出,否则必须创建一个(见Gerry的答案)。

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).

OutputDebugString()的优点是,即使呼叫进入发布版本(或者如果有意留下),应用程序也会运行,但请注意不要输出敏感信息,因为可以使用上述工具之一读取它们。

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.

您还可以创建一个ad-hoc表单(即备份控件),并在那里路由输出。

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.

这篇关于如何写入控制台窗口进行调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 19:36