C# - How to detect a Windows shutdown/logoff and cancel that action (after asking the user)

前端 未结 3 1843
长情又很酷
长情又很酷 2020-11-29 10:44

Some explanation: for a project I\'m working on I have to write a program that is running in the background, detects changes to files, and uploads the modified files to a we

3条回答
  •  攒了一身酷
    2020-11-29 10:58

    Trying to block a shutdown is a lossy proposition these days, it's no longer possible to do so in Vista and up. A prompt isn't readable nor reachable. Using a service is highly indicated here, lets you survive a user log-off. And a reboot, your service will start running again automatically, letting you complete the job.

提交回复
热议问题