Recent

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

jcmontherock

  • Sr. Member
  • ****
  • Posts: 363
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.8-64 - FPC 3.2.2

Zvoni

  • Hero Member
  • *****
  • Posts: 3466
« 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

  • Full Member
  • ***
  • Posts: 151
    • 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.6, Windows 10, https://www.youtube.com/@bsprograms
If I want to share, I give. If I want money, I sell. I don't set traps.

LeP

  • Guest
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.

 

TinyPortal © 2005-2018