如何查看OutputDebugString的输出?[英]How to view output of OutputDebugString?

I want to use OutputDebugString() in my application and then have the option to show it in a separate viewer when the application is deployed in the field.

我想在我的应用程序中使用OutputDebugString(),然后在应用程序部署到该字段时,可以选择在单独的查看器中显示它。

That is to say, I don't want to have to change a flag and rebuild my .exe to turn debugging on and off.

也就是说,我不想更改一个标志,并重新构建我的.exe来打开和关闭调试。

Googling around, it seems like DebugView should handle that, but neither it, nor TraceTool show any output from this code.

在google上搜索的时候,看起来是DebugView应该处理这个问题,但是它和TraceTool都没有显示这个代码的任何输出。

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.FormCreate(Sender: TObject);
begin
   OutputDebugString(PChar('Hello, wurld'));
end;

end.
I have read the documentation, to no avail, and see that others have had similar problems, but have not posted a solution.

我已经阅读了文档,但没有成功,并且看到其他人也有类似的问题,但是没有发布解决方案。

Is there a solution?

有解决方案吗?

5 个解决方案
#1
9  

GExperts has a debug viewer and a unit you add to your application that will do this for you, even in XE2 Starter. See the DebugIntf unit and the GExpertsDebugWindow.exe application that it includes. These work under XE2 Starter (and pretty much all other versions of Delphi).

GExperts有一个调试查看器和一个添加到您的应用程序的单元,即使在XE2启动器中也会这样做。查看DebugIntf单元和GExpertsDebugWindow。它包含的exe应用程序。这些工作在XE2 Starter(几乎所有其他版本的Delphi)下进行。

GExperts also includes tons of other IDE and editor enhancements that are great, and of course they've been around forever, so they're pretty solid tools.

GExperts还包括许多其他的IDE和编辑器增强功能,当然它们一直都存在,所以它们是非常可靠的工具。

#2
23  

The DebugView tool works fine; only be sure to launch your application directly (without the Delphi IDE or another debugger attached).

DebugView工具运行良好;只有确保直接启动应用程序(没有Delphi IDE或附加的调试器)。

Anyway, the natural way to view the OutputDebugString output for a Delphi application is to use the Delphi IDE and the Event Log Window.

无论如何,要查看Delphi应用程序的OutputDebugString输出的自然方式是使用Delphi IDE和事件日志窗口。

Enter image description here

Enter image description here

#3
5  

CnWizards contains a tool, CnDebugViewer.exe, which can capture OutputDebugString (should be run as administrator in Windows 7).

cn向导包含一个工具,CnDebugViewer。exe,它可以捕获OutputDebugString(应该在Windows 7中作为管理员运行)。

Not like DbgView, CnDebugViewer can create separated tabs for different applications.

与DbgView不同,CnDebugViewer可以为不同的应用程序创建分隔的选项卡。

CnPack contains an unit, CnDebug.pas. Using this unit, you can trace typed objects, collections, exceptions, memdump, etc. With CnDebug.pas, you also can set whether to autostart CnDebugViewer, whether dump to file while sending debug messages, etc.

CnPack包含一个单元cndebug .pa。使用这个单元,您可以跟踪类型化对象、集合、异常、memdump等。您还可以设置是否自动启动CnDebugViewer,是否在发送调试消息时转储到文件,等等。

#4
4  

One problem with using OutputDebugString is that other programs may also be using it, cluttering your log: Debugging OutputDebugString calls in Delphi.

使用OutputDebugString的一个问题是,其他程序可能也在使用它,将您的日志记录:调试OutputDebugString调用在Delphi中。

You could use CodeSite Express, which we've been very happy with in day-to-day use: http://www.raize.com/devtools/codesite/Default.asp.

您可以使用CodeSite Express,我们在日常使用中非常高兴:http://www.raize.com/devtools/codesite/Default.asp。

#5
2  

In my version of XE5, I had to enable the "Output Messages" option under:

在我的XE5版本中,我必须启用“输出消息”选项:

Tools > Options > Debugger Options > Event Log

工具>选项>调试器选项>事件日志。

I don't recall disabling it.

我不记得禁用它。

猜你喜欢

转载自blog.csdn.net/weixin_44019542/article/details/84971018
今日推荐