Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Preventing Shut Down

4 views
Skip to first unread message

Jeff Gaines

unread,
Jan 19, 2024, 9:42:30 AM1/19/24
to

Should have thought of this earlier.

New project (C# in my case) containg just thse lines:

public FormNoShutdown()
{
InitializeComponent();

this.FormClosing += new
FormClosingEventHandler(FormNoShutdown_FormClosing);
}

void FormNoShutdown_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.WindowsShutDown)
{
e.Cancel = true;
}
}

Leave it running and if Windows tries to shutdwon it will prevent it, and
you will get the standard screen asking what you want to do.

--
Jeff Gaines Dorset UK
The only thing necessary for evil to prevail is for good people to do or
say nothing. (Edmund Burke)
0 new messages