By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

Preventing Logoff / Shutdown until C# Windows App is closed

P: n/a
I developed a C# Windows App that requires a user to input their real
name and what they did to the server while they were online.

I am going to launch the app att shutdown via a logoff script.

I want to prevent the computer from logging off or shutting down until
the app is closed.

The best example I have is when you have an unsaved notepad.exe
document open and logoff or shutdown, an End Program dialog pops up
that says "The system cannot end this program because it is waiting for
a response from you". The computer will sit there forever waiting for
user response. I want that to happen with my app so they are forced to
enter data before the logoff/shutdown process continues.

How can I do this?

Jan 19 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Anyone?

mi***************@gmail.com wrote:
I developed a C# Windows App that requires a user to input their real
name and what they did to the server while they were online.

I am going to launch the app att shutdown via a logoff script.

I want to prevent the computer from logging off or shutting down until
the app is closed.

The best example I have is when you have an unsaved notepad.exe
document open and logoff or shutdown, an End Program dialog pops up
that says "The system cannot end this program because it is waiting for
a response from you". The computer will sit there forever waiting for
user response. I want that to happen with my app so they are forced to
enter data before the logoff/shutdown process continues.

How can I do this?
Jan 23 '07 #2

P: n/a
I had to figure it out myself...

With a form called 'Form1', you can use this code to do it:

(bSubmitted is a boolean that gets set to TRUE after the app submits
an entry)

private void Form1_FormClosing(object sender,
FormClosingEventArgs e)
{
if (bSubmitted == false)
{
if (MessageBox.Show("You are closing this app without
submitting an entry.\n\nAre you sure you wish to exit without
submitting?", "Warning: Not Submitted", MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Stop) == DialogResult.Yes)
return;
else
e.Cancel = true;
}
}

On Jan 22, 3:53 pm, mikemiller.inn...@gmail.com wrote:
Anyone?

mikemiller.inn...@gmail.com wrote:
I developed a C# Windows App that requires a user to input their real
name and what they did to the server while they were online.
I am going to launch the app att shutdown via a logoff script.
I want to prevent the computer from logging off or shutting down until
the app is closed.
The best example I have is when you have an unsaved notepad.exe
document open and logoff or shutdown, an End Program dialog pops up
that says "The system cannot end this program because it is waiting for
a response from you". The computer will sit there forever waiting for
user response. I want that to happen with my app so they are forced to
enter data before the logoff/shutdown process continues.
How can I do this?- Hide quoted text -

- Show quoted text -

Mar 6 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.