Click here to Skip to main content
15,889,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
At Windows Shutdown (by user) how can I display a warning message and
halt the process of windows shutdown unles user confirms if it is ok.

Thanks
Posted

1 solution

See the Form.FormClosing event[^]
Check the CloseReason property of the FormClosingEventArgs, if it is CloseReason.WindowsShutDown then set e.Cancel to True then it should prevent the form closing immediately.
Then, you can stop shutdown by using
VB
Process.Start("shutdown", "-a")
I haven't tried this in Win8 or Win10, but it should still work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900