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 AllocConsole Fenster geschlossen -> Fehler (https://www.delphipraxis.net/97844-allocconsole-fenster-geschlossen-fehler.html)

nitschchedu 17. Aug 2007 08:28


AllocConsole Fenster geschlossen -> Fehler
 
Hallo, also ich habe nun mit AllocConsole & FreeConsole rumprobiert und kann schon reinschreiben und so weiter.
Aber wenn jetzt jemand zwischen AllocConsole & FreeConsole auf das Kreuz ob geklickt hat (gelschlossen) läuft der Dienst nicht mehr richtig. Wie kann ich es Verhindern das die Konsole geschlossen würd oder wie kann ich das Prüfen ob die Konsole da ist ?

Dezipaitor 17. Aug 2007 11:58

Re: AllocConsole Fenster geschlossen -> Fehler
 
du kannst mit SetConsoleCtrlHandler auf
diese Nachrichten reagieren :

Zitat:

CTRL_C_EVENT
0 A CTRL+C signal was received, either from keyboard input or from a signal generated by the GenerateConsoleCtrlEvent function.
CTRL_BREAK_EVENT
1 A CTRL+BREAK signal was received, either from keyboard input or from a signal generated by GenerateConsoleCtrlEvent.
CTRL_CLOSE_EVENT
2 A signal that the system sends to all processes attached to a console when the user closes the console (either by clicking Close on the console window's window menu, or by clicking the End Task button command from Task Manager).
CTRL_LOGOFF_EVENT
5 A signal that the system sends to all console processes when a user is logging off. This signal does not indicate which user is logging off, so no assumptions can be made.
Note that this signal is received only by services. Interactive applications are terminated at logoff, so they are not present when the system sends this signal.
CTRL_SHUTDOWN_EVENT
6 A signal that the system sends when the system is shutting down. Interactive applications are not present by the time the system sends this signal, therefore it can be received only be services in this situation. Services also have their own notification mechanism for shutdown events. For more information, see Handler.

This signal can also be generated by an application using GenerateConsoleCtrlEvent.
Ich würde dir empfehlen auf jeden Fall auf Logoff und Shutdown zu reagieren, damit deine Anwendung nicht das Herunterfahren behindert.

nitschchedu 17. Aug 2007 12:03

Re: AllocConsole Fenster geschlossen -> Fehler
 
Ok und muss ich bei Logoff und Shutdown dann noch FreeConsole machen ?

Luckie 17. Aug 2007 12:10

Re: AllocConsole Fenster geschlossen -> Fehler
 
Ähm, wird die Konsole von deinem Dienst erzeugt und ist das ein interaktiver Dienst? Wenn ja, solltest du dir zur Kommunikation was anderes überlegen, da Microsoft unter Windows Vista diese Sicherheitslücke endlich geschlossen hat und keine interaktiven Dienste mehr gestattet.

nitschchedu 17. Aug 2007 12:17

Re: AllocConsole Fenster geschlossen -> Fehler
 
Ähh ja die Console würd vom Dienst erstellt und der Dienst ist interaktiver .... soll aber erstmal für XP sein. :mrgreen:


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:46 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