Closing application when Windows is going to sleep lazarus / 34-Windows ---------------------------------------------------------------------- jcmontherock · 2026-04-09 08:55 I want to close my application when Windows is going to sleep. Is anybody knows how to detect this event ? ---------------------------------------------------------------------- Zvoni · 2026-04-09 12:23 Best bet: https://learn.microsoft.com/en-us/windows/win32/api/powerbase/nf- powerbase-powerregistersuspendresumenotification https://learn.microsoft.com/en-us/windows/win32/api/powrprof/ns- powrprof-device_notify_subscribe_parameters https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nc- powrprof-device_notify_callback_routine No idea if the API's are available in the Windows-Unit ---------------------------------------------------------------------- Xenno · 2026-04-09 12:47 We could intercept WM_POWERBROADCAST with WParam = PBT_APMSUSPEND? ---------------------------------------------------------------------- LeP · 2026-04-09 13:14 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.