Autor Beitrag
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 02.09.06 17:12 
Hallo,

ich habe mir für Debug-Zwecke eine Unit geschrieben, die bestimmte Meldungen auf die Konsole schreibt. Diese kann man ja anschalten, indem man in den Projekteinstellungen Konsolenanwendung aktiviert.
Nun finde ich aber diese Lösung nicht schön, es sollte genügen die Unit einzubinden.
Ich habe versucht, {$APPTYPE CONSOLE} in der Unit zu verwenden, das zeigt aber keine Wirkung, oder funktioniert nur manchmal.

Wie kann ich {$APPTYPE CONSOLE} in einer Unit zum laufen kriegen oder ersatzweise eine Konsole nachträglich erzeugen?

Der Anfang der Unit sieht im Moment so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
{$APPTYPE CONSOLE}
unit DUDbgCon;

interface

uses SysUtils, Windows;


Danke,
Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Jailbird
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 127

Windows XP Pro SP2
Delphi 7 Professional
BeitragVerfasst: Sa 02.09.06 17:24 
AllocConsole und FreeConsole angucken.

Alternativ dein String im Project Source (*.dpr) platzieren.

_________________
Jailbird
Martok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 02.09.06 17:37 
Danke für die Antwort!
user profile iconJailbird hat folgendes geschrieben:
Alternativ dein String im Project Source (*.dpr) platzieren.

Geht eben nicht, ich möchte nur die Unit einbinden müssen.

user profile iconJailbird hat folgendes geschrieben:
AllocConsole und FreeConsole angucken.

Danke, Problem gelöst!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
initialization
  if AllocConsole then begin
    TTextRec(Input).Handle:= GetStdHandle(STD_INPUT_HANDLE);
    TTextRec(Output).Handle:= GetStdHandle(STD_OUTPUT_HANDLE);
    TTextRec(ErrOutput).Handle:= GetStdHandle(STD_ERROR_HANDLE);
    System.IsConsole:= true;
  end;


Funktioniert! :zustimm:

Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."