system-shutdown

How to abort shutdown in Windows (XP|Vista) programatically?

核能气质少年 提交于 2019-11-26 20:58:50
问题 I want to be able to 1. detect (and, if needed 2. abort) OS shutdown from my application, preferably by using the Windows API. I know that it is possible to abort shutdown manually using the command shutdown -a In the worst case, I could ShellExecute this, but I was wondering if there was a better way to prevent the shutdown programatically. Maybe it would be enough to be notified programatically that the OS is about to shut down - how to do this? 回答1: From MSDN: The WM_QUERYENDSESSION

How to detect pending system shutdown on Linux?

穿精又带淫゛_ 提交于 2019-11-26 20:35:30
问题 I am working on an application where I need to detect a system shutdown. However, I have not found any reliable way get a notification on this event. I know that on shutdown, my app will receive a SIGTERM signal followed by a SIGKILL . I want to know if there is any way to query if a SIGTERM is part of a shutdown sequence ? Does any one know if there is a way to query that programmatically (C API)? As far as I know, the system does not provide any other method to query for an impending

How to power down the computer from a freestanding environment?

时光怂恿深爱的人放手 提交于 2019-11-26 14:31:17
问题 I'm making a protected-mode OS based on Intel's x86 architecture, and was looking for some information on how to power off the computer via assembly code, or something like that. Could you help me with this problem? 回答1: from http://forum.osdev.org/viewtopic.php?t=16990 The ACPI shutdown is technically a really simple thing all that is needed is a outw(PM1a_CNT, SLP_TYPa | SLP_EN ); and the computer is powered off. The problem lies in the gathering of these values especially since the SLP

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

纵饮孤独 提交于 2019-11-26 09:55:02
问题 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 web service to make it available to others. Quite simple synchronization if it were not for the case when a user modifies a big file and decides to shutdown its computer right after the edit. I could cancel the upload and wait for the next reboot to do the upload, but I can imagine the user downloading the file from the web

How to detect Windows shutdown or logoff

喜夏-厌秋 提交于 2019-11-26 03:38:03
问题 I need to detect when Windows is shutdown (or restarted) or when the user is logging off. I need to properly close the application before the application is closed. I noticed that no exit application event is raised when Windows is closing day. I read the post Is there a way in c# to detect a Windows shutdown/logoff and cancel that action (after asking the user) but I\'m not sure of where I should perform the operations before closing. Thanks. 回答1: Attach an event handler method to the