更新时间:2022-12-23 12:18:51
那很简单
Thats simple
// SystemEvents class is present in Microsoft.Win32
//e.Cancel=true will terminate the log off or shutdown procedure
SystemEvents.SessionEnding += new SessionEndingEventHandler((o, e) => { e.Cancel = true; MessageBox.Show("unable to shutdown computer myApplicetion is running"); });
要在系统关闭时处理(接受/拒绝)应用程序关闭,请处理 ^ ]事件.特别是,请参见 CloseReason
[
To handle (accept/reject) app shutdown when the sytem is shutting down, handle theFormClosing
[^] event. In particular, see theCloseReason
[^] property.
/ravi