Home > front end >  The Windows equivalent of /lib/systemd/system-sleep/ for suspend notification
The Windows equivalent of /lib/systemd/system-sleep/ for suspend notification

Time:12-28

My application, in C, compiled with VisualC 2019, needs to know when the OS goes to sleep.

Under Linux, I use /lib/systemd/system-sleep/ for this, where you can simply place a script that gets run on going to sleep/suspend.

In Windows, what would be the way to achieve this in the C programming language?

I need my app to do some housekeeping just before the OS goes to sleep, so I need a trigger for that.

I want to avoid C# and dot Net, so would like to achieve this with plain function calls into the Windows OS.

CodePudding user response:

Listen for WM_POWERBROADCAST or call PowerRegisterSuspendResumeNotification.

  • Related