Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 247
Mawg says reinstate Monica Avatar asked Jun 27 '12 02:06

Mawg says reinstate Monica


People also ask

How do I view Windows debug Logs?

To enable debug logging information and open the debug log file: Select Preferences from the Preferences Toolbar. The Viewer/General dialog box displays. Click the Error Log File check box.

What is debug viewer?

DebugView is an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP.

What is OutputDebugString?

The debugapi. h header defines OutputDebugString as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant.


1 Answers

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

like image 67
RRUZ Avatar answered Sep 20 '22 16:09

RRUZ