Recent

Author Topic: [CLOSED] How do I disable the app from closing.  (Read 4837 times)

loaded

  • Hero Member
  • *****
  • Posts: 824
[CLOSED] How do I disable the app from closing.
« on: October 26, 2021, 07:54:09 am »
Hi All,
With the code below; I prevent the application from closing.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
  2. begin
  3.  CloseAction :=caNone;
  4. end;
But applications such as Taskmanager or Process Explorer can easily close it.
How can I block external shutdown calls?

By the way, there is one more thing I want to know!
Some applications cannot be closed in any way, how do they achieve this, so what is the method?
I would be grateful if you share your knowledge. Respects.
« Last Edit: October 26, 2021, 11:29:38 am by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: How do I disable the app from closing.
« Reply #1 on: October 26, 2021, 08:54:12 am »
But applications such as Taskmanager or Process Explorer can easily close it.

That's the purpose of these applications.

How can I block external shutdown calls?

Please, just don't. There is nothing more annoying than an application that does this and this will turn into an arms race between you and yours users.

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: How do I disable the app from closing.
« Reply #2 on: October 26, 2021, 09:58:23 am »
Please, just don't. There is nothing more annoying than an application that does this and this will turn into an arms race between you and yours users.

I agree with you. Therefore ; You are right to think so.
But I wish I had written my purpose beforehand. ;D
I wanted to make Server-User style control software for controlling computers used by students in School Libraries. While I was reviewing possible scenarios, I wanted to consult you when the possibility of being turned off by talented students arose.
That's the whole point!!!
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: How do I disable the app from closing.
« Reply #3 on: October 26, 2021, 10:02:53 am »
Services are usually used to make "hidden" applications. They can't be stopped without admin rights. Everything beyond this - is something like drivers with self-protection, that are used in anti-viruses.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: How do I disable the app from closing.
« Reply #4 on: October 26, 2021, 10:45:29 am »
One approach is to have two processes running, each one able to restart the other. But I totally agree with PD, its a bad path to go down. Especially if your target user base is students ...

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: How do I disable the app from closing.
« Reply #5 on: October 26, 2021, 11:10:27 am »
While I was reviewing possible scenarios, I wanted to consult you when the possibility of being turned off by talented students arose.

If your operating system allows unauthorised users access to that sort of thing then you're running the wrong operating system, or you need to hire people who can advise you on how to toughen it up.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: How do I disable the app from closing.
« Reply #6 on: October 26, 2021, 11:29:12 am »
Guys, you are all very right.  :)
However, I am a lone wolf. So you have to think for a while that I'm right too.
Anyways; it doesn't matter though. good luck to you all.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: [CLOSED] How do I disable the app from closing.
« Reply #7 on: October 26, 2021, 11:49:08 am »
Unclose-able program is annoying. But I can understand sometimes we need it.

I haven't tried but maybe this will work.

When the program started, it starts a service. The service will regularly check to make sure the 'main' program is running. It will restart the main program if it is not running. You can use IPC to let the service 'ask' if the main program is running.

https://wiki.lazarus.freepascal.org/Daemons_and_Services
« Last Edit: October 26, 2021, 11:56:45 am by Handoko »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: [CLOSED] How do I disable the app from closing.
« Reply #8 on: October 26, 2021, 12:00:16 pm »
But a suitably-skilled user can terminate services. "Any sufficiently advanced technology is indistinguishable from magic"... perhaps that's why people talk about access rites :-)

I don't know what the current situation is, but when Windows NT was in vogue there was a 40-something page document from- I think- the US Navy which talked about configuring it to be adequately robust. Allowing for the explosion in just about everything computer-related, there must surely be stuff like that in circulation for recent Windows variants.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: [CLOSED] How do I disable the app from closing.
« Reply #9 on: October 26, 2021, 12:31:33 pm »
Thanks friends. The information you have provided is sufficient for a start.
A little bit, I will wander from the forest of Lazarus to the vast mountains of google. Maybe I'll come across a wise owl.  :)
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: How do I disable the app from closing.
« Reply #10 on: October 27, 2021, 09:13:53 am »
I wanted to make Server-User style control software for controlling computers used by students in School Libraries. While I was reviewing possible scenarios, I wanted to consult you when the possibility of being turned off by talented students arose.

I had already suspected that it will be something like this. The main point will be that the stundent accounts must not be accounts with administrative access. Then you can either use a service as others suggested (in that case if you need to display something to the user you'll need a separate application that runs in the user's context and communicates with your service) or make sure that your application is started by the system and thus runs with higher privileges. Then the students won't be able to kill your application.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: How do I disable the app from closing.
« Reply #11 on: October 27, 2021, 09:25:14 am »
I had already suspected that it will be something like this. The main point will be that the stundent accounts must not be accounts with administrative access.

I can't resist throwing this in as a cautionary tale. Years ago, somebody on CIX (a British conferencing system) encountered a restaurant remote-ordering system set up using Windows NT... probably chosen because it was understood to be a good foundation for robust central systems.

It comprised a dial-in remote-access desktop, with full admin rights, on which was running a standard desktop program. Leaving the start button, taskbar facilities and so on completely unprotected.

It no doubt looked very pretty, but I can't help but feel that somebody had missed the point.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jollytall

  • Sr. Member
  • ****
  • Posts: 306
Re: [CLOSED] How do I disable the app from closing.
« Reply #12 on: October 27, 2021, 10:10:59 am »
Under Linux and C++ I can hijack the signals Interrupt and Terminate. Once they are hijacked, I can do anything with it, even ignore.
I know Signals are Unix-like specific animals and that FPC/Lazarus is cross platform and thus looking at these things more in an abstract way, but my question would be, whether and how I can use the same C++ trick under Pascal in Linux?

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: [CLOSED] How do I disable the app from closing.
« Reply #13 on: October 27, 2021, 10:15:21 am »
Use the same code. See BaseUnix.

Note however that you can't block the kill signal.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jollytall

  • Sr. Member
  • ****
  • Posts: 306
Re: [CLOSED] How do I disable the app from closing.
« Reply #14 on: October 27, 2021, 02:48:20 pm »
Thanks,
I indeed could make it for SIGINT and SIGTERM, but not for SIGKILL.

 

TinyPortal © 2005-2018