0

I was wondering if there is a way to intercept a restart which has been executed by and external application, so i can post a command to an API to say the machine is restarting and then restart the machine myself?

Regards

B

BillyDay
  • 37
  • 1
  • 4
  • 14
  • A shutdown or restart should be _detectable_ but I doubt it is possible to cancel it from "user space" or even be granted enough time to make an API call _reliably_. – Fildor May 05 '20 at 11:21
  • 1
    You can use `WM_ENDSESSION` event to detect shutdown. Then, you can use ShutdownBlockReasonCreate to block the shutdown until your call is done. Here's a blog post with more details https://www.meziantou.net/prevent-windows-shutdown-or-session-ending-in-dotnet.htm – meziantou May 05 '20 at 13:37

0 Answers0