Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

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

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

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

Enter image description here

Enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...