Application ist aber in der
Unit Forms deklariert. Kann ich das trotzdem verwenden, indem ich forms.pas einbinde oder gibt es eine Entsprechung bei Konsolenanwendungen?
Yes you can add Forms to console application, but it is not enough and will not solve your problem as himitsu said, you should capture the signals instead, this is cleaner and the right way with consoles.
To capture these events you need to use SetConsoleCtrlHandler
https://learn.microsoft.com/en-us/wi...olectrlhandler
https://learn.microsoft.com/en-us/wi...handlerroutine
Something like this :
Code:
function HandlerRoutine(dwCtrlType: DWORD): Bool; stdcall;
begin
Result := false;
if (CTRL_C_EVENT = dwCtrlType) or (CTRL_BREAK_EVENT = dwCtrlType) then
begin
Result := true;
end;
end;
// setup the callback routine
SetConsoleCtrlHandler(@HandlerRoutine, True);