Recent

Author Topic: Closing application when Windows is going to sleep  (Read 891 times)

jcmontherock

  • Sr. Member
  • ****
  • Posts: 353
Closing application when Windows is going to sleep
« on: April 09, 2026, 10:55:13 am »
I want to close my application when Windows is going to sleep. Is anybody knows how to detect this event ?
« Last Edit: April 09, 2026, 10:58:22 am by jcmontherock »
Windows 11 UTF8-64 - Lazarus 4.6-64 - FPC 3.2.2

Zvoni

  • Hero Member
  • *****
  • Posts: 3367
« Last Edit: April 09, 2026, 02:25:21 pm by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Xenno

  • Jr. Member
  • **
  • Posts: 88
    • BS Programs
Re: Closing application when Windows is going to sleep
« Reply #2 on: April 09, 2026, 02:47:10 pm »
We could intercept WM_POWERBROADCAST with WParam = PBT_APMSUSPEND?
Lazarus 4.0, Windows 10, https://www.youtube.com/@bsprograms

LeP

  • Sr. Member
  • ****
  • Posts: 294
Re: Closing application when Windows is going to sleep
« Reply #3 on: April 09, 2026, 03:14:32 pm »
In the modern system with modern CPU, the "sleep" is differentiate in various level.

In some of them no signal in generated to the user applications when those (sleep modes) switch on.
The system simply freeze and wake up after some times like nothnig happens.
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

 

TinyPortal © 2005-2018