Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Normale Anwendung mit Konsole (https://www.delphipraxis.net/8636-normale-anwendung-mit-konsole.html)

Motzi 9. Sep 2003 12:46


Normale Anwendung mit Konsole
 
Hi,

ich würde bei einer Anwendung optional gerne eine Konsole zur Verfügung stellen. D.h. ich habe eine normale Anwendung und erzeuge mir meine Console erst bei Bedarf mit AllocConsole - kein Problem soweit, allerdings würde ich auch bei dieser Console gerne die komfortablen Funktionen Read(ln)/Write(ln) verwenden. Die Delphi-Hilfe besagt jedoch:
Zitat:

When an application is compiled as a console application (using the Generate console application checkbox on the Linker page of the Project|Options dialog, or a -cc command line switch with the command-line compiler), Delphi automatically associates the Input and Output files with the application's console window. For non-console applications, any attempt to read from Input or write to Output will generate an I/O error.
Da mein Programm jedoch nicht als Konsolenanwendung gelinkt wird werden die Input/Ouput-Handles nicht mit der Konsole verknüpft (kann ja auch gar nicht gehn...)

Meine Frage jetzt - wisst ihr vielleicht zufällig wie man das selbst machen könnte? Ich weiß zwar wie ich die Input/Output-Handles der Console setze etc, aber wie mache ich das so, dass ich ganz normal per Read(ln)/Write(ln) in diese Console schreibe bzw lese?

Motzi 9. Sep 2003 14:18

Re: Normale Anwendung mit Konsole
 
Hab mir mal den genauen Ablauf eines Aufrufs von WriteLn/ReadLn angeschaut und festgestellt, dass da intern immer wieder das Input- bzw Output-Handle der aktuellen Konsole ermittelt und damit gearbeitet wird. Es reicht also eine Console mittels AllocConsole zu erzeugen und man kann trotzdem wie gewohnt mit den Befehlen arbeiten, auch wenn die Anwendung eigentlich gar nicht als Konsolenanwendung konzipiert wurde...


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:35 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz